use of eu.esdihumboldt.hale.io.geoserver.Namespace in project hale by halestudio.
the class AppSchemaMappingUploader method publishNamespaces.
private void publishNamespaces() {
NamespaceManager nsMgr = new NamespaceManager(geoserverURL);
nsMgr.setCredentials(username, password);
// check whether main namespace/workspace exists; if not, create it
Namespace mainNs = generator.getMainNamespace();
createNamespaceIfRequired(nsMgr, mainNs);
// check whether secondary namespaces/workspaces exist; if not, create
// them
List<Namespace> secondaryNamespaces = generator.getSecondaryNamespaces();
for (Namespace ns : secondaryNamespaces) {
createNamespaceIfRequired(nsMgr, ns);
}
}
use of eu.esdihumboldt.hale.io.geoserver.Namespace 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.io.geoserver.Namespace 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.io.geoserver.Namespace 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.io.geoserver.Namespace in project hale by halestudio.
the class NamespaceResourceTest method testSerializeDefault.
/**
* Tests the correct serialization of a namespace resource where only
* {@code prefix} and {@code uri} are set.
*
* @throws Exception if an error occurs parsing the resource as XML
*/
@Test
public void testSerializeDefault() throws Exception {
Namespace testNamespace = ResourceBuilder.namespace(TEST_PREFIX).setAttribute(Namespace.URI, TEST_URI).build();
Document doc = parseResource(testNamespace);
assertEquals(1, doc.getElementsByTagName(ELEMENT_NAMESPACE).getLength());
Node namespaceEl = doc.getElementsByTagName(ELEMENT_NAMESPACE).item(0);
Map<String, String> expectedValues = new HashMap<>();
expectedValues.put(ELEMENT_PREFIX, TEST_PREFIX);
expectedValues.put(ELEMENT_URI, TEST_URI);
expectedValues.put(ELEMENT_ISOLATED, "false");
checkResource(namespaceEl, expectedValues);
}
Aggregations