use of eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter in project hale by halestudio.
the class AppSchemaIsolatedWorkspacesMappingTest method testBothIsolated.
/**
* Isolated attribute must be true, names must match those specified in the
* workspace configuration, unique mapping names must be generated.
*
* @throws IOException
*/
@Test
public void testBothIsolated() throws IOException {
workspaceConf.getWorkspaces().forEach(ws -> ws.setIsolated(true));
AppSchemaMappingGenerator generator = new AppSchemaMappingGenerator(alignment, targetSchemaSpace, null, featureChainingConf, workspaceConf);
IOReporter reporter = new DefaultIOReporter(targetSchemaSpace.getSchemas().iterator().next(), "Generate App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, false);
generator.generateMapping(reporter);
assertEquals(STATIONS_WS_RENAMED, generator.getMainNamespace().name());
assertTrue((boolean) generator.getMainNamespace().getAttribute(Namespace.ISOLATED));
assertEquals(STATIONS_WS_RENAMED, generator.getMainWorkspace().name());
assertTrue((boolean) generator.getMainWorkspace().getAttribute(Namespace.ISOLATED));
boolean measurementsNsFound = false;
for (Namespace ns : generator.getSecondaryNamespaces()) {
if (MEASUREMENTS_NS_URI.equals(ns.getAttribute(Namespace.URI))) {
measurementsNsFound = true;
assertEquals(MEASUREMENTS_WS_RENAMED, ns.name());
assertTrue((boolean) ns.getAttribute(Namespace.ISOLATED));
assertEquals(MEASUREMENTS_WS_RENAMED, generator.getWorkspace(ns).name());
assertTrue((boolean) generator.getWorkspace(ns).getAttribute(Namespace.ISOLATED));
}
}
assertTrue(measurementsNsFound);
List<FeatureTypeMapping> typeMappings = generator.getGeneratedMapping().getAppSchemaMapping().getTypeMappings().getFeatureTypeMapping();
assertEquals(2, typeMappings.size());
Set<String> mappingNames = new HashSet<String>();
for (FeatureTypeMapping typeMapping : typeMappings) {
assertFalse(Strings.isNullOrEmpty(typeMapping.getMappingName()));
mappingNames.add(typeMapping.getMappingName());
}
assertEquals(2, mappingNames.size());
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter in project hale by halestudio.
the class AppSchemaIsolatedWorkspacesMappingTest method testNonIsolatedRenamed.
/**
* Isolated attribute must be false, names must match those specified in the
* workspace configuration, unique mapping names must not be generated.
*
* @throws IOException
*/
@Test
public void testNonIsolatedRenamed() throws IOException {
AppSchemaMappingGenerator generator = new AppSchemaMappingGenerator(alignment, targetSchemaSpace, null, featureChainingConf, workspaceConf);
IOReporter reporter = new DefaultIOReporter(targetSchemaSpace.getSchemas().iterator().next(), "Generate App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, false);
generator.generateMapping(reporter);
assertEquals(STATIONS_WS_RENAMED, generator.getMainNamespace().name());
assertFalse((boolean) generator.getMainNamespace().getAttribute(Namespace.ISOLATED));
assertEquals(STATIONS_WS_RENAMED, generator.getMainWorkspace().name());
assertFalse((boolean) generator.getMainWorkspace().getAttribute(Namespace.ISOLATED));
boolean measurementsNsFound = false;
for (Namespace ns : generator.getSecondaryNamespaces()) {
if (MEASUREMENTS_NS_URI.equals(ns.getAttribute(Namespace.URI))) {
measurementsNsFound = true;
assertEquals(MEASUREMENTS_WS_RENAMED, ns.name());
assertFalse((boolean) ns.getAttribute(Namespace.ISOLATED));
assertEquals(MEASUREMENTS_WS_RENAMED, generator.getWorkspace(ns).name());
assertFalse((boolean) generator.getWorkspace(ns).getAttribute(Namespace.ISOLATED));
}
}
assertTrue(measurementsNsFound);
List<FeatureTypeMapping> typeMappings = generator.getGeneratedMapping().getAppSchemaMapping().getTypeMappings().getFeatureTypeMapping();
assertEquals(2, typeMappings.size());
for (FeatureTypeMapping typeMapping : typeMappings) {
assertTrue(Strings.isNullOrEmpty(typeMapping.getMappingName()));
}
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter in project hale by halestudio.
the class AppSchemaIsolatedWorkspacesMappingTest method testStationsIsolated.
/**
* Isolated attribute must be true for the stations ws and false for the
* measurements ws, names must match those specified in the workspace
* configuration, unique mapping names must be generated only for the
* stations ws.
*
* @throws IOException
*/
@Test
public void testStationsIsolated() throws IOException {
workspaceConf.getWorkspace(STATIONS_NS_URI).setIsolated(true);
AppSchemaMappingGenerator generator = new AppSchemaMappingGenerator(alignment, targetSchemaSpace, null, featureChainingConf, workspaceConf);
IOReporter reporter = new DefaultIOReporter(targetSchemaSpace.getSchemas().iterator().next(), "Generate App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, false);
generator.generateMapping(reporter);
assertEquals(STATIONS_WS_RENAMED, generator.getMainNamespace().name());
assertTrue((boolean) generator.getMainNamespace().getAttribute(Namespace.ISOLATED));
assertEquals(STATIONS_WS_RENAMED, generator.getMainWorkspace().name());
assertTrue((boolean) generator.getMainWorkspace().getAttribute(Namespace.ISOLATED));
boolean measurementsNsFound = false;
for (Namespace ns : generator.getSecondaryNamespaces()) {
if (MEASUREMENTS_NS_URI.equals(ns.getAttribute(Namespace.URI))) {
measurementsNsFound = true;
assertEquals(MEASUREMENTS_WS_RENAMED, ns.name());
assertFalse((boolean) ns.getAttribute(Namespace.ISOLATED));
assertEquals(MEASUREMENTS_WS_RENAMED, generator.getWorkspace(ns).name());
assertFalse((boolean) generator.getWorkspace(ns).getAttribute(Namespace.ISOLATED));
}
}
assertTrue(measurementsNsFound);
List<FeatureTypeMapping> typeMappings = generator.getGeneratedMapping().getAppSchemaMapping().getTypeMappings().getFeatureTypeMapping();
assertEquals(2, typeMappings.size());
boolean stationsFtFound = false, measurementsFtFound = false;
Set<String> mappingNames = new HashSet<String>();
for (FeatureTypeMapping typeMapping : typeMappings) {
if ((STATIONS_WS_RENAMED + ":Station_gml32").equals(typeMapping.getTargetElement())) {
stationsFtFound = true;
assertFalse(Strings.isNullOrEmpty(typeMapping.getMappingName()));
}
if ((MEASUREMENTS_WS_RENAMED + ":Measurement_gml32").equals(typeMapping.getTargetElement())) {
measurementsFtFound = true;
assertTrue(Strings.isNullOrEmpty(typeMapping.getMappingName()));
}
if (!Strings.isNullOrEmpty(typeMapping.getMappingName())) {
mappingNames.add(typeMapping.getMappingName());
}
}
assertEquals(1, mappingNames.size());
assertTrue(stationsFtFound);
assertTrue(measurementsFtFound);
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter in project hale by halestudio.
the class JaxbAlignmentIO method printCell.
/**
* Print a cell to an output stream (intended for tests/debugging).
*
* @param cell the cell to print
* @param out the output stream
* @throws Exception if an error occurs trying to print the cell
*/
public static void printCell(MutableCell cell, OutputStream out) throws Exception {
DefaultAlignment alignment = new DefaultAlignment();
alignment.addCell(cell);
IOReporter reporter = new DefaultIOReporter(new Locatable() {
@Override
public URI getLocation() {
return null;
}
}, "Print cell", null, false);
PathUpdate pathUpdate = new PathUpdate(null, null);
AlignmentType at = convert(alignment, reporter, pathUpdate);
CellType ct = (CellType) at.getCellOrModifier().get(0);
JAXBContext jc = JAXBContext.newInstance(ALIGNMENT_CONTEXT, ObjectFactory.class.getClassLoader());
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
ObjectFactory of = new ObjectFactory();
try {
m.marshal(of.createCell(ct), out);
} finally {
out.flush();
out.close();
}
}
Aggregations