use of eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter in project hale by halestudio.
the class HaleConnectProjectWriter method createReporter.
/**
* @see IOProvider#createReporter()
*/
@Override
public IOReporter createReporter() {
if (!(haleConnect instanceof BasePathResolver) || !HaleConnectUrnBuilder.isValidProjectUrn(getTarget().getLocation())) {
return super.createReporter();
}
try {
URI targetUri = getTarget().getLocation();
Locatable prettifiedTarget = new LocatableURI(prettifyTarget(targetUri));
return new DefaultIOReporter(prettifiedTarget, MessageFormat.format("{0} export", getTypeName()), getActionId(), true);
} catch (Throwable t) {
return super.createReporter();
}
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter in project hale by halestudio.
the class AppSchemaIsolatedWorkspacesMappingTest method testNullWorkspaceConfiguration.
/**
* Isolated attribute must be false, names must match the default ones,
* unique mapping names must not be generated.
*
* @throws IOException
*/
@Test
public void testNullWorkspaceConfiguration() throws IOException {
AppSchemaMappingGenerator generator = new AppSchemaMappingGenerator(alignment, targetSchemaSpace, null, featureChainingConf, null);
IOReporter reporter = new DefaultIOReporter(targetSchemaSpace.getSchemas().iterator().next(), "Generate App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, false);
generator.generateMapping(reporter);
assertEquals(STATIONS_WS_DEFAULT, generator.getMainNamespace().name());
assertFalse((boolean) generator.getMainNamespace().getAttribute(Namespace.ISOLATED));
assertEquals(STATIONS_WS_DEFAULT, 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_DEFAULT, ns.name());
assertFalse((boolean) ns.getAttribute(Namespace.ISOLATED));
assertEquals(MEASUREMENTS_WS_DEFAULT, 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 WorkspaceConfigurationPage method updateWorkspaceTable.
private void updateWorkspaceTable() {
AbstractAppSchemaConfigurator configurator = getWizard().getProvider();
DefaultIOReporter reporter = new DefaultIOReporter(configurator.getTarget(), "Generate Temporary App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, true);
AppSchemaMappingGenerator generator;
try {
configurator.generateMapping(reporter);
generator = configurator.getMappingGenerator();
AppSchemaDataAccessType appSchemaMapping = generator.getGeneratedMapping().getAppSchemaMapping();
List<FeatureTypeMapping> typeMappings = appSchemaMapping.getTypeMappings().getFeatureTypeMapping();
for (FeatureTypeMapping typeMapping : typeMappings) {
String[] workspaceAndType = typeMapping.getTargetElement().split(":");
String workspaceName = workspaceAndType[0];
String typeName = workspaceAndType[1];
List<Namespace> namespaces = appSchemaMapping.getNamespaces().getNamespace();
for (Namespace namespace : namespaces) {
if (workspaceName.equals(namespace.getPrefix())) {
String uri = namespace.getUri();
if (workspaceConf.hasWorkspace(uri)) {
workspaceConf.getWorkspace(uri).getFeatureTypes().add(typeName);
} else {
WorkspaceMetadata workspace = new WorkspaceMetadata(workspaceName, uri);
workspace.getFeatureTypes().add(typeName);
workspaceConf.addWorkspace(workspace);
}
}
}
}
// remove workspaces that contain no features
workspaceConf.getWorkspaces().forEach((ws) -> {
if (ws.getFeatureTypes().isEmpty()) {
workspaceConf.removeWorkspace(ws.getNamespaceUri());
}
});
workspaceTableViewer.setInput(workspaceConf.getWorkspaces());
reporter.setSuccess(true);
} catch (Exception e) {
reporter.error(new IOMessageImpl(e.getMessage(), e));
reporter.setSuccess(false);
}
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter in project hale by halestudio.
the class TestUtil method loadAlignment.
/**
* Loads the specified alignment. Assumes that its base alignments don't
* need a location update.
*
* @param location the URI specifying the location of the alignment
* @param sourceTypes the source type index
* @param targetTypes the target type index
* @return the loaded alignment
* @throws Exception if the alignment or other resources could not be loaded
*/
public static Alignment loadAlignment(final URI location, Schema sourceTypes, Schema targetTypes) throws Exception {
DefaultInputSupplier input = new DefaultInputSupplier(location);
IOReporter report = new DefaultIOReporter(new Locatable() {
@Override
public URI getLocation() {
return location;
}
}, "Load alignment", AlignmentIO.ACTION_LOAD_ALIGNMENT, true);
Alignment alignment;
try {
alignment = CastorAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null));
} catch (Exception e) {
alignment = JaxbAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null), null, null);
}
assertTrue("Errors are contained in the report", report.getErrors().isEmpty());
return alignment;
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter in project hale by halestudio.
the class HaleConnectProjectReader method createReporter.
/**
* @see eu.esdihumboldt.hale.common.core.io.impl.AbstractImportProvider#createReporter()
*/
@Override
public IOReporter createReporter() {
if (!(getSource() instanceof HaleConnectInputSupplier) || !HaleConnectUrnBuilder.isValidProjectUrn(getSource().getLocation())) {
return super.createReporter();
}
try {
BasePathResolver resolver = ((HaleConnectInputSupplier) getSource()).getBasePathResolver();
URI sourceUri = getSource().getLocation();
Owner owner = HaleConnectUrnBuilder.extractProjectOwner(sourceUri);
String projectId = HaleConnectUrnBuilder.extractProjectId(sourceUri);
String clientBasePath = resolver.getBasePath(HaleConnectServices.WEB_CLIENT);
Locatable prettifiedTarget = new LocatableURI(HaleConnectUrnBuilder.buildClientAccessUrl(clientBasePath, owner, projectId));
return new DefaultIOReporter(prettifiedTarget, MessageFormat.format("{0} import", getTypeName()), getActionId(), true);
} catch (Throwable t) {
return super.createReporter();
}
}
Aggregations