Search in sources :

Example 1 with ResourceSchemaSpace

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);
}
Also used : ResourceSchemaSpace(eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace)

Example 2 with ResourceSchemaSpace

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;
}
Also used : ResourceSchemaSpace(eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace) Schema(eu.esdihumboldt.hale.common.schema.model.Schema)

Example 3 with ResourceSchemaSpace

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;
}
Also used : ResourceSchemaSpace(eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with ResourceSchemaSpace

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;
    }
}
Also used : ResourceSchemaSpace(eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace)

Example 5 with ResourceSchemaSpace

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.");
    }
}
Also used : IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) ResourceSchemaSpace(eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) NullProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.NullProgressIndicator) IContentType(org.eclipse.core.runtime.content.IContentType) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) AlignmentWriter(eu.esdihumboldt.hale.common.align.io.AlignmentWriter)

Aggregations

ResourceSchemaSpace (eu.esdihumboldt.hale.common.schema.model.impl.ResourceSchemaSpace)5 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)2 AlignmentWriter (eu.esdihumboldt.hale.common.align.io.AlignmentWriter)1 IOProviderDescriptor (eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor)1 NullProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.NullProgressIndicator)1 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)1 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IContentType (org.eclipse.core.runtime.content.IContentType)1