Search in sources :

Example 6 with SchemaService

use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.

the class SpectrumColorSchemeHandler method execute.

/**
 * @see IHandler#execute(ExecutionEvent)
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // collect all types
    SetMultimap<DataSet, TypeDefinition> types = HashMultimap.create();
    SchemaService schemas = PlatformUI.getWorkbench().getService(SchemaService.class);
    for (TypeDefinition type : schemas.getSchemas(SchemaSpaceID.SOURCE).getMappingRelevantTypes()) {
        types.put(DataSet.SOURCE, type);
    }
    for (TypeDefinition type : schemas.getSchemas(SchemaSpaceID.TARGET).getMappingRelevantTypes()) {
        types.put(DataSet.TRANSFORMED, type);
    }
    Style style = StyleHelper.getSpectrumStyles(types);
    StyleService styleService = PlatformUI.getWorkbench().getService(StyleService.class);
    styleService.addStyles(style);
    return null;
}
Also used : DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) StyleService(eu.esdihumboldt.hale.ui.common.service.style.StyleService) Style(org.geotools.styling.Style) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 7 with SchemaService

use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.

the class MarkTypeUnmappableHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
        SchemaService schemaService = PlatformUI.getWorkbench().getService(SchemaService.class);
        Iterator<?> it = ((IStructuredSelection) selection).iterator();
        List<TypeDefinition> sourceTypes = new ArrayList<>();
        List<TypeDefinition> targetTypes = new ArrayList<>();
        while (it.hasNext()) {
            Object selected = it.next();
            TypeDefinition type = null;
            if (selected instanceof TypeEntityDefinition) {
                type = ((TypeEntityDefinition) selected).getDefinition();
            } else if (selected instanceof TypeDefinition) {
                type = (TypeDefinition) selected;
            }
            if (type != null) {
                if (schemaService.getSchemas(SchemaSpaceID.SOURCE).getMappingRelevantTypes().contains(type)) {
                    sourceTypes.add(type);
                } else {
                    targetTypes.add(type);
                }
            }
        }
        if (!sourceTypes.isEmpty()) {
            schemaService.toggleMappable(SchemaSpaceID.SOURCE, sourceTypes);
        }
        if (!targetTypes.isEmpty()) {
            schemaService.toggleMappable(SchemaSpaceID.TARGET, targetTypes);
        }
    }
    return null;
}
Also used : TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 8 with SchemaService

use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.

the class TransformDataExportAdvisor method prepareProvider.

/**
 * @see IOAdvisor#prepareProvider(IOProvider)
 */
@Override
public void prepareProvider(InstanceWriter provider) {
    super.prepareProvider(provider);
    // set target schema
    SchemaService ss = getService(SchemaService.class);
    provider.setTargetSchema(ss.getSchemas(SchemaSpaceID.TARGET));
    // set instances to export
    provider.setInstances(instances);
}
Also used : SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService)

Example 9 with SchemaService

use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.

the class InstanceValidationReportDetailsContentProvider method inputChanged.

/**
 * @see ITreePathContentProvider#inputChanged(Viewer, Object, Object)
 */
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
    childCache.clear();
    messages.clear();
    limitedPaths.clear();
    if (newInput instanceof Collection<?>) {
        SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
        TreePath emptyPath = new TreePath(new Object[0]);
        for (Object o : (Collection<?>) newInput) {
            if (o instanceof InstanceValidationMessage) {
                InstanceValidationMessage message = ((InstanceValidationMessage) o);
                Set<Object> baseTypes = childCache.get(emptyPath);
                if (baseTypes == null) {
                    baseTypes = new HashSet<Object>();
                    childCache.put(emptyPath, baseTypes);
                }
                // XXX maybe expand messages with SSID?
                TypeDefinition typeDef = null;
                if (message.getType() != null) {
                    typeDef = ss.getSchemas(SchemaSpaceID.TARGET).getType(message.getType());
                }
                // use typeDef if available, QName otherwise
                Object use = typeDef == null ? message.getType() : typeDef;
                if (use == null) {
                    // fall-back to generic category
                    use = "General";
                }
                baseTypes.add(use);
                messages.put(new TreePath(new Object[] { use }), message);
            }
        }
    }
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) Collection(java.util.Collection) InstanceValidationMessage(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationMessage) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 10 with SchemaService

use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.

the class AbstractTargetAction method run.

@Override
public void run() {
    // if Display not the active Thread
    if (Display.getCurrent() == null) {
        // execute in display thread
        PlatformUI.getWorkbench().getDisplay().asyncExec(this);
        return;
    }
    if (params == null || params.isEmpty()) {
        return;
    }
    // retrieve the target schema
    SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
    SchemaSpace targetSchema = ss.getSchemas(SchemaSpaceID.TARGET);
    // find type
    QName typeName = QName.valueOf(params.get(0));
    TypeDefinition type = targetSchema.getType(typeName);
    if (type == null) {
        // check all mapping relevant types for local name only
        for (TypeDefinition candidate : targetSchema.getMappingRelevantTypes()) {
            if (candidate.getName().getLocalPart().equals(params.get(0))) {
                // use the first found
                type = candidate;
                break;
            }
        }
    }
    if (type != null) {
        EntityDefinition entity = new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null);
        if (params.size() > 1) {
            // determine property entity
            EntityAccessor accessor = new EntityAccessor(entity);
            for (int i = 1; i < params.size(); i++) {
                QName propertyName = QName.valueOf(params.get(i));
                String namespace = propertyName.getNamespaceURI();
                if (namespace != null && namespace.isEmpty()) {
                    // treat empty namespace as ignoring namespace
                    namespace = null;
                }
                accessor = accessor.findChildren(propertyName.getLocalPart(), namespace);
            }
            entity = accessor.toEntityDefinition();
        }
        if (entity != null) {
            run(entity, manager);
        } else {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Schema element not found", "The schema element was not found in the target schema, please make sure the correct schema is loaded.");
        }
    } else {
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Schema element not found", MessageFormat.format("The type {0} was not found in the target schema, please make sure the correct schema is loaded.", typeName.getLocalPart()));
    }
}
Also used : EntityAccessor(eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) QName(javax.xml.namespace.QName) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Aggregations

SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)29 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)8 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)4 SchemaSpace (eu.esdihumboldt.hale.common.schema.model.SchemaSpace)3 ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)2 XmlElement (eu.esdihumboldt.hale.io.xsd.model.XmlElement)2 StyledDefinitionLabelProvider (eu.esdihumboldt.hale.ui.common.definition.viewer.StyledDefinitionLabelProvider)2 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)2 EntityDefinitionService (eu.esdihumboldt.hale.ui.service.entity.EntityDefinitionService)2 EntityTypeIndexContentProvider (eu.esdihumboldt.hale.ui.service.entity.util.EntityTypeIndexContentProvider)2 EntityTypeIndexHierarchy (eu.esdihumboldt.hale.ui.service.entity.util.EntityTypeIndexHierarchy)2 TreePathProviderAdapter (eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathProviderAdapter)2 QName (javax.xml.namespace.QName)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 GridData (org.eclipse.swt.layout.GridData)2 Label (org.eclipse.swt.widgets.Label)2 EntityAccessor (eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor)1 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1