use of eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace in project hale by halestudio.
the class SchemaServiceImpl method addSchema.
/**
* @see eu.esdihumboldt.hale.ui.service.schema.SchemaService#addSchema(java.lang.String,
* eu.esdihumboldt.hale.common.schema.model.Schema,
* eu.esdihumboldt.hale.common.schema.SchemaSpaceID)
*/
@Override
public void addSchema(String resourceID, Schema schema, SchemaSpaceID spaceID) {
Preconditions.checkNotNull(spaceID);
SchemaIO.loadMappingRelevantTypesConfig(schema, spaceID, getProjectService().getConfigurationService());
ResourceSchemaSpace space = (ResourceSchemaSpace) getSchemas(spaceID);
space.addSchema(resourceID, schema);
notifySchemaAdded(spaceID, schema);
}
use of eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace in project hale by halestudio.
the class SchemaServiceImpl method removeSchema.
/**
* @see eu.esdihumboldt.hale.ui.service.schema.SchemaService#removeSchema(java.lang.String,
* eu.esdihumboldt.hale.common.schema.SchemaSpaceID)
*/
@Override
public boolean removeSchema(String resourceID, SchemaSpaceID spaceID) {
Preconditions.checkNotNull(spaceID);
ResourceSchemaSpace space = (ResourceSchemaSpace) getSchemas(spaceID);
Schema removedSchema = space.removeSchema(resourceID);
notifySchemaRemoved(spaceID);
notifyMappableTypesChanged(spaceID, space.getTypes());
return removedSchema != null ? true : false;
}
use of eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace in project hale by halestudio.
the class LoadSchemaAdvisor method getSchema.
/**
* Get the accumulated schemas.
*
* @return the schema space
*/
public SchemaSpace getSchema() {
// TODO cache?
ResourceSchemaSpace dss = new ResourceSchemaSpace();
// add all schemas
for (Map.Entry<String, Schema> entry : schemas.entrySet()) {
// load information about mapping relevant types
SchemaIO.loadMappingRelevantTypesConfig(entry.getValue(), ssid, project);
dss.addSchema(entry.getKey(), entry.getValue());
}
return dss;
}
use of eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace in project hale by halestudio.
the class SchemaServiceImpl method getSchemas.
/**
* @see SchemaService#getSchemas(SchemaSpaceID)
*/
@Override
public SchemaSpace getSchemas(SchemaSpaceID spaceID) {
Preconditions.checkNotNull(spaceID);
synchronized (spaces) {
ResourceSchemaSpace space = spaces.get(spaceID);
if (space == null) {
space = new ResourceSchemaSpace();
spaces.put(spaceID, space);
}
return space;
}
}
use of eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace in project hale by halestudio.
the class GenerateDefaults method writeAlignment.
private void writeAlignment() throws Exception {
System.out.println("Writing alignment to " + context.getOut().getAbsolutePath());
// create alignment writer
IContentType contentType = HalePlatform.getContentTypeManager().getContentType(ALIGNMENT_CONTENT_TYPE);
IOProviderDescriptor factory = HaleIO.findIOProviderFactory(AlignmentWriter.class, contentType, null);
AlignmentWriter writer = (AlignmentWriter) factory.createExtensionObject();
// configure alignment writer
writer.setTargetSchema(new ResourceSchemaSpace().addSchema(resourceId, schema));
writer.setTarget(new FileIOSupplier(context.getOut()));
writer.setAlignment(alignment);
IOReport report = writer.execute(new NullProgressIndicator());
if (!report.isSuccess() || !report.getErrors().isEmpty()) {
throw new IllegalStateException("Errors while writing the alignment.");
} else {
System.out.println("Completed successfully.");
}
}
Aggregations