Search in sources :

Example 6 with TypeEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition in project hale by halestudio.

the class UserMigration method entityReplacement.

@Override
public Optional<EntityDefinition> entityReplacement(EntityDefinition entity, SimpleLog log) {
    // use functionality from entity resolver
    if (entity instanceof TypeEntityDefinition) {
        EntityDefinition candidate = entity;
        Type type = UserFallbackEntityResolver.resolveType((TypeEntityDefinition) entity, candidate, schemaSpace);
        return Optional.ofNullable(type).map(e -> e.getDefinition());
    } else if (entity instanceof PropertyEntityDefinition) {
        EntityDefinition candidate = entity;
        candidate = EntityCandidates.find((PropertyEntityDefinition) entity);
        Property property = UserFallbackEntityResolver.resolveProperty((PropertyEntityDefinition) entity, candidate, schemaSpace);
        return Optional.ofNullable(property).map(e -> e.getDefinition());
    } else {
        log.error("Unrecognised entity type: " + entity.getClass());
        return Optional.empty();
    }
}
Also used : Property(eu.esdihumboldt.hale.common.align.model.Property) SimpleLog(eu.esdihumboldt.hale.common.core.report.SimpleLog) Type(eu.esdihumboldt.hale.common.align.model.Type) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) Optional(java.util.Optional) UserFallbackEntityResolver(eu.esdihumboldt.hale.ui.service.align.resolver.UserFallbackEntityResolver) EntityCandidates(eu.esdihumboldt.hale.ui.service.align.resolver.internal.EntityCandidates) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) AlignmentMigration(eu.esdihumboldt.hale.common.align.migrate.AlignmentMigration) SchemaSpaceID(eu.esdihumboldt.hale.common.schema.SchemaSpaceID) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) Type(eu.esdihumboldt.hale.common.align.model.Type) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) Property(eu.esdihumboldt.hale.common.align.model.Property)

Example 7 with TypeEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition in project hale by halestudio.

the class EntityTypeIndexHierarchy method getChildren.

/**
 * @see ITreeContentProvider#getChildren(Object)
 */
@Override
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof EntityDefinition) {
        EntityDefinition parent = (EntityDefinition) parentElement;
        List<EntityDefinition> children = new ArrayList<EntityDefinition>();
        // add valid sub types and alternative type entities
        if (parent.getPropertyPath().isEmpty() && parent.getFilter() == null) {
            // add valid sub types w/o filter
            for (TypeDefinition subtype : parent.getType().getSubTypes()) {
                if (validTypes.contains(subtype)) {
                    children.add(new TypeEntityDefinition(subtype, parent.getSchemaSpace(), null));
                }
            }
            // add type contexts
            for (TypeEntityDefinition typeEntity : entityDefinitionService.getTypeEntities(parent.getType(), parent.getSchemaSpace())) {
                if (typeEntity.getFilter() != null) {
                    // only use type entities with filter defined
                    children.add(typeEntity);
                }
            }
        }
        if (!onlyTypes) {
            // add regular children
            children.addAll(entityDefinitionService.getChildren(parent));
        }
        return children.toArray();
    } else {
        throw new IllegalArgumentException("Given element not supported in schema tree structure.");
    }
}
Also used : 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) ArrayList(java.util.ArrayList) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 8 with TypeEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition in project hale by halestudio.

the class EntityTypeIndexHierarchy method getElements.

/**
 * @see ITreeContentProvider#getElements(Object)
 */
@Override
public Object[] getElements(Object inputElement) {
    if (inputElement instanceof TypeIndex) {
        validTypes = new HashSet<TypeDefinition>();
        List<TypeEntityDefinition> roots = new ArrayList<TypeEntityDefinition>();
        Queue<TypeDefinition> types = new LinkedList<TypeDefinition>();
        if (onlyMappingRelevant)
            types.addAll(((TypeIndex) inputElement).getMappingRelevantTypes());
        else {
            for (TypeDefinition type : ((TypeIndex) inputElement).getTypes()) if (type.getConstraint(MappableFlag.class).isEnabled())
                types.add(type);
        }
        // collect types and super types in valid types set
        while (!types.isEmpty()) {
            TypeDefinition type = types.poll();
            if (!validTypes.contains(type)) {
                validTypes.add(type);
                TypeDefinition superType = type.getSuperType();
                if (superType != null && !validTypes.contains(superType)) {
                    types.add(superType);
                }
                if (superType == null) {
                    // add default type as root
                    roots.add(new TypeEntityDefinition(type, schemaSpace, null));
                }
            }
        }
        // }
        return roots.toArray();
    } else {
        throw new IllegalArgumentException("Content provider only applicable for type indexes.");
    }
}
Also used : TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) TypeIndex(eu.esdihumboldt.hale.common.schema.model.TypeIndex) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 9 with TypeEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition in project hale by halestudio.

the class PopulationServiceImpl method addToPopulation.

/**
 * @see PopulationService#addToPopulation(Instance, DataSet)
 */
@Override
public void addToPopulation(Instance instance, DataSet dataSet) {
    SchemaSpaceID schemaSpace;
    if (dataSet != null) {
        switch(dataSet) {
            case TRANSFORMED:
                schemaSpace = SchemaSpaceID.TARGET;
                break;
            case SOURCE:
            default:
                schemaSpace = SchemaSpaceID.SOURCE;
        }
    } else {
        throw new IllegalArgumentException("Invalid data set specified.");
    }
    // count for each Type definitions of instance type
    Collection<? extends TypeEntityDefinition> typeDefinitions = entityDefinitionService.getTypeEntities(instance.getDefinition(), schemaSpace);
    for (TypeEntityDefinition def : typeDefinitions) {
        if (def.getFilter() == null || def.getFilter().match(instance)) {
            increase(def, 1);
            populationCount.addToPopulation(instance, def);
        }
    }
}
Also used : TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) SchemaSpaceID(eu.esdihumboldt.hale.common.schema.SchemaSpaceID)

Example 10 with TypeEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition in project hale by halestudio.

the class PropertyEntitiesPage method createHeader.

/**
 * @see EntitiesPage#createHeader(Composite)
 */
@Override
protected Control createHeader(Composite parent) {
    Group typeSelectionGroup = new Group(parent, SWT.NONE);
    typeSelectionGroup.setText("Type");
    typeSelectionGroup.setLayout(new GridLayout());
    sourceTargetSelector = new SourceTargetTypeSelector(typeSelectionGroup);
    sourceTargetSelector.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    // set initial selection
    sourceTargetSelector.setSelection(getInitialTypeSelection(SchemaSpaceID.SOURCE), SchemaSpaceID.SOURCE);
    sourceTargetSelector.setSelection(getInitialTypeSelection(SchemaSpaceID.TARGET), SchemaSpaceID.TARGET);
    // add selection listener
    sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            TypeEntityDefinition selectedType = sourceTargetSelector.getSelection(SchemaSpaceID.SOURCE);
            for (PropertyField field : getFunctionFields()) {
                if (field.getSchemaSpace() == SchemaSpaceID.SOURCE) {
                    field.setParentType(selectedType);
                }
            }
        }
    }, SchemaSpaceID.SOURCE);
    sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            TypeEntityDefinition selectedType = sourceTargetSelector.getSelection(SchemaSpaceID.TARGET);
            for (PropertyField field : getFunctionFields()) if (field.getSchemaSpace() == SchemaSpaceID.TARGET)
                field.setParentType(selectedType);
        }
    }, SchemaSpaceID.TARGET);
    return typeSelectionGroup;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyField(eu.esdihumboldt.hale.ui.function.generic.pages.internal.PropertyField) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) SourceTargetTypeSelector(eu.esdihumboldt.hale.ui.function.common.SourceTargetTypeSelector)

Aggregations

TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)64 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)23 ArrayList (java.util.ArrayList)19 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)16 Type (eu.esdihumboldt.hale.common.align.model.Type)16 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)16 DefaultType (eu.esdihumboldt.hale.common.align.model.impl.DefaultType)15 Cell (eu.esdihumboldt.hale.common.align.model.Cell)14 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)12 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)11 JoinParameter (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter)10 QName (javax.xml.namespace.QName)9 MutableAlignment (eu.esdihumboldt.hale.common.align.model.MutableAlignment)8 DefaultAlignment (eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)8 JoinCondition (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)6 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)6 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)6 LinkedList (java.util.LinkedList)6 Entity (eu.esdihumboldt.hale.common.align.model.Entity)5 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)5