Search in sources :

Example 11 with DefaultTypeDefinition

use of eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition in project hale by halestudio.

the class MapTypeProvider method getOrCreateType.

@Override
public DefaultTypeDefinition getOrCreateType(QName typeName, Value id) {
    DefaultTypeDefinition type = map.get(id);
    if (type == null) {
        type = new DefaultTypeDefinition(typeName);
        map.put(id, type);
    }
    return type;
}
Also used : DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)

Example 12 with DefaultTypeDefinition

use of eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition in project hale by halestudio.

the class PropertyFunctionScriptPage method createBindingDummy.

private TypeDefinition createBindingDummy(Class<?> clazz) {
    DefaultTypeDefinition type = new DefaultTypeDefinition(new QName(clazz.getName()));
    type.setConstraint(Binding.get(clazz));
    type.setConstraint(HasValueFlag.ENABLED);
    return type;
}
Also used : DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) QName(javax.xml.namespace.QName)

Example 13 with DefaultTypeDefinition

use of eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition in project hale by halestudio.

the class PropertyFunctionScriptPage method addActions.

@Override
protected void addActions(ToolBar toolbar, CompilingSourceViewer<GroovyAST> viewer) {
    super.addActions(toolbar, viewer);
    PageHelp.createToolItem(toolbar, this);
    TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.SOURCE, new TypeProvider() {

        @Override
        public Collection<? extends TypeDefinition> getTypes() {
            // create a dummy type with the variables as children
            DefaultTypeDefinition dummy = new DefaultTypeDefinition(TypeStructureTray.VARIABLES_TYPE_NAME);
            DefaultCustomPropertyFunction cf = getWizard().getUnfinishedFunction();
            int index = 0;
            for (EntityDefinition variable : getVariables()) {
                DefaultCustomPropertyFunctionEntity source = cf.getSources().get(index);
                if (variable.getDefinition() instanceof PropertyDefinition) {
                    PropertyDefinition prop = (PropertyDefinition) variable.getDefinition();
                    TypeDefinition propertyType;
                    boolean useInstanceValue = CustomGroovyTransformation.useInstanceVariableForSource(source);
                    if (useInstanceValue) {
                        // use instance type
                        propertyType = prop.getPropertyType();
                    } else {
                        // use dummy type with only the
                        // binding/HasValueFlag copied
                        DefaultTypeDefinition crippledType = new DefaultTypeDefinition(prop.getPropertyType().getName());
                        crippledType.setConstraint(prop.getPropertyType().getConstraint(Binding.class));
                        crippledType.setConstraint(prop.getPropertyType().getConstraint(HasValueFlag.class));
                        propertyType = crippledType;
                    }
                    DefaultPropertyDefinition dummyProp = new DefaultPropertyDefinition(new QName(source.getName()), dummy, propertyType);
                    // number of times
                    if (source.isEager())
                        dummyProp.setConstraint(Cardinality.CC_ANY_NUMBER);
                }
                index++;
            }
            return Collections.singleton(dummy);
        }
    });
    TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.TARGET, new TypeProvider() {

        @Override
        public Collection<? extends TypeDefinition> getTypes() {
            DefaultCustomPropertyFunctionEntity target = getWizard().getUnfinishedFunction().getTarget();
            if (target != null) {
                return Collections.singleton(createDummyType(target));
            }
            return Collections.emptyList();
        }
    });
}
Also used : DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) QName(javax.xml.namespace.QName) TypeProvider(eu.esdihumboldt.hale.ui.functions.groovy.internal.TypeStructureTray.TypeProvider) Collection(java.util.Collection) DefaultCustomPropertyFunctionEntity(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunctionEntity) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 14 with DefaultTypeDefinition

use of eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition in project hale by halestudio.

the class GroovyTransformationPage method addActions.

@Override
protected void addActions(ToolBar toolbar, CompilingSourceViewer<GroovyAST> viewer) {
    super.addActions(toolbar, viewer);
    PageHelp.createToolItem(toolbar, this);
    TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.SOURCE, new TypeProvider() {

        @Override
        public Collection<? extends TypeDefinition> getTypes() {
            // create a dummy type with the variables as children
            DefaultTypeDefinition dummy = new DefaultTypeDefinition(TypeStructureTray.VARIABLES_TYPE_NAME);
            Cell cell = getWizard().getUnfinishedCell();
            boolean useInstanceValues = CellUtil.getOptionalParameter(cell, GroovyTransformation.PARAM_INSTANCE_VARIABLES, Value.of(false)).as(Boolean.class);
            for (EntityDefinition variable : getVariables()) {
                if (variable.getDefinition() instanceof PropertyDefinition) {
                    PropertyDefinition prop = (PropertyDefinition) variable.getDefinition();
                    TypeDefinition propertyType;
                    if (useInstanceValues) {
                        // use instance type
                        propertyType = prop.getPropertyType();
                    } else {
                        // use dummy type with only the
                        // binding/HasValueFlag copied
                        DefaultTypeDefinition crippledType = new DefaultTypeDefinition(prop.getPropertyType().getName());
                        crippledType.setConstraint(prop.getPropertyType().getConstraint(Binding.class));
                        crippledType.setConstraint(prop.getPropertyType().getConstraint(HasValueFlag.class));
                        propertyType = crippledType;
                    }
                    DefaultPropertyDefinition dummyProp = new DefaultPropertyDefinition(new QName(getVariableName(variable)), dummy, propertyType);
                    // number of times
                    if (cell.getTransformationIdentifier().equals(GroovyGreedyTransformation.ID))
                        dummyProp.setConstraint(Cardinality.CC_ANY_NUMBER);
                }
            }
            return Collections.singleton(dummy);
        }
    });
    TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.TARGET, new TypeProvider() {

        @Override
        public Collection<? extends TypeDefinition> getTypes() {
            Property targetProperty = (Property) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
            if (targetProperty != null) {
                return Collections.singleton(targetProperty.getDefinition().getDefinition().getPropertyType());
            }
            return Collections.emptyList();
        }
    });
    PageFunctions.createToolItem(toolbar, this);
}
Also used : DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) QName(javax.xml.namespace.QName) TypeProvider(eu.esdihumboldt.hale.ui.functions.groovy.internal.TypeStructureTray.TypeProvider) Collection(java.util.Collection) Cell(eu.esdihumboldt.hale.common.align.model.Cell) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) Property(eu.esdihumboldt.hale.common.align.model.Property) DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 15 with DefaultTypeDefinition

use of eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition in project hale by halestudio.

the class CustomTypeContentHelper method replaceTypeForProperty.

private static void replaceTypeForProperty(PropertyDefinition propDef, DefinitionGroup propParent, TypeDefinition newPropertyType) {
    PropertyDefinition newProperty;
    if (propDef instanceof PropertyTypeOverrideProperty) {
        newProperty = new PropertyTypeOverrideProperty(((PropertyTypeOverrideProperty) propDef).getDecoratedProperty(), newPropertyType);
    } else {
        newProperty = new PropertyTypeOverrideProperty(propDef, newPropertyType);
    }
    if (propParent instanceof DefaultTypeDefinition) {
        DefaultTypeDefinition type = (DefaultTypeDefinition) propParent;
        type.overrideChild(newProperty);
    } else // else if (propParent instanceof DefaultGroupPropertyDefinition) {
    // // TODO
    // }
    {
        log.error("Could not update custom content property because of unsupported parent definition group");
    }
}
Also used : DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) PropertyTypeOverrideProperty(eu.esdihumboldt.hale.common.schema.model.impl.PropertyTypeOverrideProperty) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) DefaultGroupPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultGroupPropertyDefinition) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)

Aggregations

DefaultTypeDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)28 QName (javax.xml.namespace.QName)23 DefaultPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition)18 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)15 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)7 Filter (eu.esdihumboldt.hale.common.instance.model.Filter)5 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)4 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)4 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)4 DefaultGroupPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultGroupPropertyDefinition)4 DefaultSchema (eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchema)4 IOException (java.io.IOException)4 Test (org.junit.Test)4 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)3 MutableInstance (eu.esdihumboldt.hale.common.instance.model.MutableInstance)3 GeometryProperty (eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty)3 Cell (eu.esdihumboldt.hale.common.align.model.Cell)2 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)2 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)2 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)2