Search in sources :

Example 6 with DefaultType

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

the class AppSchemaMappingTest method testRetypeHandler.

@Test
public void testRetypeHandler() {
    DefaultCell cell = new DefaultCell();
    cell.setTransformationIdentifier(RetypeFunction.ID);
    ListMultimap<String, Type> source = ArrayListMultimap.create();
    source.put(null, new DefaultType(new TypeEntityDefinition(unitDenormType, SchemaSpaceID.SOURCE, null)));
    ListMultimap<String, Type> target = ArrayListMultimap.create();
    target.put(null, new DefaultType(new TypeEntityDefinition(landCoverUnitType, SchemaSpaceID.TARGET, null)));
    cell.setSource(source);
    cell.setTarget(target);
    RetypeHandler handler = new RetypeHandler();
    FeatureTypeMapping ftMapping = handler.handleTypeTransformation(cell, new AppSchemaMappingContext(mappingWrapper));
    assertEquals(SOURCE_UNIT_DENORM, ftMapping.getSourceType());
    assertEquals("lcv:LandCoverUnit", ftMapping.getTargetElement());
}
Also used : Type(eu.esdihumboldt.hale.common.align.model.Type) AttributeMappingType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType) AppSchemaDataAccessType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) AppSchemaMappingContext(eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) RetypeHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.RetypeHandler) Test(org.junit.Test)

Example 7 with DefaultType

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

the class AppSchemaMappingTest method buildJoinCell.

@SuppressWarnings("null")
private DefaultCell buildJoinCell(FeatureChaining chainingConf) {
    boolean withChaining = chainingConf != null;
    DefaultCell joinCell = new DefaultCell();
    joinCell.setTransformationIdentifier(JoinFunction.ID);
    if (withChaining) {
        // set cell ID from feature chaining configuration
        // WARNING: this code assumes only one join is configured
        joinCell.setId(chainingConf.getJoins().keySet().iterator().next());
    }
    TypeEntityDefinition datasetEntityDef = new TypeEntityDefinition(datasetType, SchemaSpaceID.SOURCE, null);
    TypeEntityDefinition unitEntityDef = null;
    TypeEntityDefinition observationEntityDef = null;
    if (!withChaining) {
        unitEntityDef = new TypeEntityDefinition(unitDenormType, SchemaSpaceID.SOURCE, null);
    } else {
        unitEntityDef = new TypeEntityDefinition(unitType, SchemaSpaceID.SOURCE, null);
        observationEntityDef = new TypeEntityDefinition(observationType, SchemaSpaceID.SOURCE, null);
    }
    ListMultimap<String, Type> source = ArrayListMultimap.create();
    source.put(JoinFunction.JOIN_TYPES, new DefaultType(datasetEntityDef));
    source.put(JoinFunction.JOIN_TYPES, new DefaultType(unitEntityDef));
    if (observationEntityDef != null) {
        source.put(JoinFunction.JOIN_TYPES, new DefaultType(observationEntityDef));
        assertEquals(3, source.get(JoinFunction.JOIN_TYPES).size());
    } else {
        assertEquals(2, source.get(JoinFunction.JOIN_TYPES).size());
    }
    ListMultimap<String, Type> target = ArrayListMultimap.create();
    target.put(null, new DefaultType(new TypeEntityDefinition(landCoverDatasetType, SchemaSpaceID.TARGET, null)));
    List<TypeEntityDefinition> types = new ArrayList<TypeEntityDefinition>(Arrays.asList(datasetEntityDef, unitEntityDef));
    Set<JoinCondition> conditions = new HashSet<JoinCondition>();
    // join dataset and unit
    PropertyEntityDefinition baseProperty = getDatasetIdSourceProperty().values().iterator().next().getDefinition();
    PropertyEntityDefinition joinProperty = getUnitDatasetIdSourceProperty(unitEntityDef.getType()).values().iterator().next().getDefinition();
    conditions.add(new JoinCondition(baseProperty, joinProperty));
    if (withChaining) {
        // add observation type
        types.add(observationEntityDef);
        // join unit and observation
        baseProperty = getUnitIdSourceProperty(unitEntityDef.getType()).values().iterator().next().getDefinition();
        joinProperty = getObservationUnitIdSourceProperty().values().iterator().next().getDefinition();
        conditions.add(new JoinCondition(baseProperty, joinProperty));
    }
    JoinParameter joinParam = new JoinParameter(types, conditions);
    ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
    parameters.put(JoinFunction.PARAMETER_JOIN, new ParameterValue(new ComplexValue(joinParam)));
    joinCell.setSource(source);
    joinCell.setTarget(target);
    joinCell.setTransformationParameters(parameters);
    return joinCell;
}
Also used : ComplexValue(eu.esdihumboldt.hale.common.core.io.impl.ComplexValue) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) ArrayList(java.util.ArrayList) JoinParameter(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter) JoinCondition(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) Type(eu.esdihumboldt.hale.common.align.model.Type) AttributeMappingType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType) AppSchemaDataAccessType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) HashSet(java.util.HashSet)

Example 8 with DefaultType

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

the class DefaultCellMigrator method updateCell.

@Override
public MutableCell updateCell(final Cell originalCell, final AlignmentMigration migration, final MigrationOptions options, SimpleLog log) {
    MutableCell result = new DefaultCell(originalCell);
    SimpleLog cellLog = SimpleLog.all(log, new CellLog(result, CELL_LOG_CATEGORY));
    final AtomicBoolean replacedEntities = new AtomicBoolean(false);
    EntryTransformer<String, Entity, Entity> entityTransformer = new EntryTransformer<String, Entity, Entity>() {

        @Override
        public Entity transformEntry(String key, Entity value) {
            EntityDefinition org = value.getDefinition();
            Optional<EntityDefinition> replace = migration.entityReplacement(org, cellLog);
            EntityDefinition entity = replace.orElse(org);
            if (!Objects.equal(entity, org)) {
                replacedEntities.set(true);
            }
            if (entity instanceof PropertyEntityDefinition) {
                return new DefaultProperty((PropertyEntityDefinition) entity);
            } else if (entity instanceof TypeEntityDefinition) {
                return new DefaultType((TypeEntityDefinition) entity);
            } else {
                throw new IllegalStateException("Invalid entity definition for creating entity");
            }
        }
    };
    // update source entities
    if (options.updateSource() && result.getSource() != null && !result.getSource().isEmpty()) {
        result.setSource(ArrayListMultimap.create(Multimaps.transformEntries(result.getSource(), entityTransformer)));
    }
    // update target entities
    if (options.updateTarget() && result.getTarget() != null && !result.getTarget().isEmpty()) {
        result.setTarget(ArrayListMultimap.create(Multimaps.transformEntries(result.getTarget(), entityTransformer)));
    }
    // TODO anything else?
    postUpdateCell(result, options, replacedEntities.get(), cellLog);
    return result;
}
Also used : SimpleLog(eu.esdihumboldt.hale.common.core.report.SimpleLog) Entity(eu.esdihumboldt.hale.common.align.model.Entity) MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) EntryTransformer(com.google.common.collect.Maps.EntryTransformer) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) DefaultProperty(eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) 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) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) CellLog(eu.esdihumboldt.hale.common.align.model.annotations.messages.CellLog)

Example 9 with DefaultType

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

the class DefaultAlignmentIOTest method testSaveLoad.

/**
 * Test saving and loading an example alignment
 *
 * @throws Exception if an error occurs
 */
@Test
public void testSaveLoad() throws Exception {
    // populate alignment
    MutableAlignment align = new DefaultAlignment();
    DefaultSchema source = new DefaultSchema("", null);
    DefaultSchema target = new DefaultSchema("", null);
    // cell 1
    MutableCell cell1 = new DefaultCell();
    String id1;
    cell1.setTransformationIdentifier(id1 = "trans1");
    ListMultimap<String, ParameterValue> parameters1 = LinkedListMultimap.create();
    parameters1.put("test", new ParameterValue("1"));
    parameters1.put("test", new ParameterValue("2"));
    parameters1.put("t", new ParameterValue("3"));
    cell1.setTransformationParameters(parameters1);
    if (supportsTransformationModes()) {
        cell1.setTransformationMode(TransformationMode.passive);
    }
    ListMultimap<String, Type> source1 = ArrayListMultimap.create();
    QName source1TypeName;
    String source1EntityName;
    TypeDefinition sourceType1 = new DefaultTypeDefinition(source1TypeName = new QName("source1Type"));
    String filterText = "someproperty > 12";
    Filter filter = new FilterGeoCqlImpl(filterText);
    source1.put(source1EntityName = null, new DefaultType(new TypeEntityDefinition(sourceType1, SchemaSpaceID.SOURCE, filter)));
    cell1.setSource(source1);
    source.addType(sourceType1);
    ListMultimap<String, Type> target1 = ArrayListMultimap.create();
    QName target1TypeName;
    String target1EntityName;
    TypeDefinition targetType1 = new DefaultTypeDefinition(target1TypeName = new QName("http://some.name.space/t1", "target1Type"));
    target1.put(target1EntityName = "Some name", new DefaultType(new TypeEntityDefinition(targetType1, SchemaSpaceID.TARGET, null)));
    cell1.setTarget(target1);
    target.addType(targetType1);
    align.addCell(cell1);
    // cell 2
    MutableCell cell2 = new DefaultCell();
    String id2;
    cell2.setTransformationIdentifier(id2 = "trans2");
    ListMultimap<String, ParameterValue> parameters2 = LinkedListMultimap.create();
    parameters2.put("test", new ParameterValue("4"));
    parameters2.put("tx", new ParameterValue("5"));
    parameters2.put("tx", new ParameterValue("6"));
    // complex parameter value
    if (supportsComplexParameters()) {
        TestAnnotation commentParam = new TestAnnotation();
        commentParam.setAuthor("Gerd");
        commentParam.setComment("Should a comment really be used as parameter?");
        parameters2.put("comment", new ParameterValue(Value.complex(commentParam)));
    }
    cell2.setTransformationParameters(parameters2);
    ListMultimap<String, Type> target2 = ArrayListMultimap.create();
    TypeDefinition targetType2 = new DefaultTypeDefinition(new QName("target2Type"));
    target2.put("Some other name", new DefaultType(new TypeEntityDefinition(targetType2, SchemaSpaceID.TARGET, null)));
    cell2.setTarget(target2);
    target.addType(targetType2);
    align.addCell(cell2);
    TestAnnotation ann1 = null;
    TestAnnotation ann2 = null;
    if (supportsAnnotations()) {
        // add some annotations
        ann1 = (TestAnnotation) cell2.addAnnotation("test");
        ann1.setAuthor("Simon");
        ann1.setComment("I have really no idea what I did here");
        ann2 = (TestAnnotation) cell2.addAnnotation("test");
        ann2.setAuthor("Hans");
        ann2.setComment("Me neither");
    }
    String doc1 = "This cell was created in memory of...\nSorry, forgotten.";
    String tag1 = "This is a tag";
    String tag2 = "awesome";
    if (supportsDocumentation()) {
        cell1.getDocumentation().put(null, doc1);
        cell1.getDocumentation().put("tag", tag1);
        cell1.getDocumentation().put("tag", tag2);
    }
    // write alignment
    File alignmentFile = tmp.newFile("alignment.xml");
    System.out.println(alignmentFile.getAbsolutePath());
    saveAlignment(align, new BufferedOutputStream(new FileOutputStream(alignmentFile)));
    // load alignment
    // TODO use and check reporter?
    MutableAlignment align2 = loadAlignment(new FileInputStream(alignmentFile), source, target);
    // compare loaded alignment
    Collection<? extends Cell> cells = align2.getCells();
    assertFalse(cells.isEmpty());
    Iterator<? extends Cell> it = cells.iterator();
    // cell 1
    Cell ncell1 = it.next();
    assertNotNull(ncell1);
    assertEquals(id1, ncell1.getTransformationIdentifier());
    // documentation
    if (supportsDocumentation()) {
        assertEquals(3, ncell1.getDocumentation().size());
        assertEquals(doc1, ncell1.getDocumentation().get(null).get(0));
        assertEquals(tag1, ncell1.getDocumentation().get("tag").get(0));
        assertEquals(tag2, ncell1.getDocumentation().get("tag").get(1));
    }
    if (supportsTransformationModes()) {
        assertEquals(TransformationMode.passive, ncell1.getTransformationMode());
    }
    // source 1
    ListMultimap<String, ? extends Entity> source1Entities = ncell1.getSource();
    assertEquals(1, source1Entities.size());
    List<? extends Entity> s1list = source1Entities.get(source1EntityName);
    assertFalse(s1list.isEmpty());
    assertEquals(source1TypeName, s1list.get(0).getDefinition().getDefinition().getName());
    // filter
    assertEquals(filter, s1list.get(0).getDefinition().getFilter());
    // target 1
    ListMultimap<String, ? extends Entity> target1Entities = ncell1.getTarget();
    assertEquals(1, target1Entities.size());
    List<? extends Entity> t1list = target1Entities.get(target1EntityName);
    assertFalse(t1list.isEmpty());
    assertEquals(target1TypeName, t1list.get(0).getDefinition().getDefinition().getName());
    // cell 2
    Cell ncell2 = it.next();
    assertNotNull(ncell2);
    assertEquals(id2, ncell2.getTransformationIdentifier());
    // parameters
    ListMultimap<String, ParameterValue> param2 = ncell2.getTransformationParameters();
    if (!supportsComplexParameters()) {
        assertEquals(2, param2.keySet().size());
        assertEquals(3, param2.values().size());
    } else {
        assertEquals(3, param2.keySet().size());
        assertEquals(4, param2.values().size());
        ParameterValue complexParam = param2.get("comment").get(0);
        assertTrue(complexParam.getValue() instanceof TestAnnotation);
    }
    // annotations
    if (supportsAnnotations()) {
        List<?> annotations = ncell2.getAnnotations("test");
        assertEquals(2, annotations.size());
        TestAnnotation nann1 = (TestAnnotation) annotations.get(0);
        assertEquals(ann1, nann1);
        TestAnnotation nann2 = (TestAnnotation) annotations.get(1);
        assertEquals(ann2, nann2);
    }
}
Also used : MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) FilterGeoCqlImpl(eu.esdihumboldt.hale.common.filter.FilterGeoCqlImpl) DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) DefaultSchema(eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchema) DefaultAlignment(eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment) BufferedOutputStream(java.io.BufferedOutputStream) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) BaseAlignmentCell(eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell) Cell(eu.esdihumboldt.hale.common.align.model.Cell) ModifiableCell(eu.esdihumboldt.hale.common.align.model.ModifiableCell) MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) QName(javax.xml.namespace.QName) MutableAlignment(eu.esdihumboldt.hale.common.align.model.MutableAlignment) FileInputStream(java.io.FileInputStream) Type(eu.esdihumboldt.hale.common.align.model.Type) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) Filter(eu.esdihumboldt.hale.common.instance.model.Filter) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Test(org.junit.Test)

Example 10 with DefaultType

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

the class DefaultAlignmentIOTest method testCellDisableSaveLoad.

/**
 * Tests cell disable save and load.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testCellDisableSaveLoad() throws Exception {
    DefaultAlignment baseAlignment = new DefaultAlignment();
    MutableAlignment alignment = new DefaultAlignment();
    Schema schema = TestUtil.loadSchema(getClass().getResource("/testdata/simple/t1.xsd").toURI());
    Iterator<? extends TypeDefinition> iter = schema.getMappingRelevantTypes().iterator();
    TypeDefinition t = iter.next();
    if (!t.getName().getLocalPart().equals("T1")) {
        t = iter.next();
    }
    // generate base alignment
    DefaultCell cell1 = new DefaultCell();
    cell1.setTransformationIdentifier("trans1");
    ListMultimap<String, Type> source = ArrayListMultimap.create();
    source.put(null, new DefaultType(new TypeEntityDefinition(t, SchemaSpaceID.SOURCE, null)));
    cell1.setSource(source);
    ListMultimap<String, Type> target = ArrayListMultimap.create();
    target.put(null, new DefaultType(new TypeEntityDefinition(t, SchemaSpaceID.TARGET, null)));
    cell1.setTarget(target);
    DefaultCell cell2 = new DefaultCell();
    cell2.setTransformationIdentifier("trans2");
    List<ChildContext> childContext2 = new ArrayList<ChildContext>();
    PropertyDefinition child2 = DefinitionUtil.getChild(t, new QName("a1")).asProperty();
    childContext2.add(new ChildContext(child2));
    ListMultimap<String, Property> source2 = ArrayListMultimap.create();
    source2.put(null, new DefaultProperty(new PropertyEntityDefinition(t, childContext2, SchemaSpaceID.SOURCE, null)));
    cell2.setSource(source2);
    ListMultimap<String, Property> target2 = ArrayListMultimap.create();
    target2.put(null, new DefaultProperty(new PropertyEntityDefinition(t, childContext2, SchemaSpaceID.TARGET, null)));
    cell2.setTarget(target2);
    DefaultCell cell3 = new DefaultCell();
    cell3.setTransformationIdentifier("trans3");
    List<ChildContext> childContext3 = new ArrayList<ChildContext>();
    PropertyDefinition child3 = DefinitionUtil.getChild(t, new QName("b1")).asProperty();
    childContext3.add(new ChildContext(child3));
    ListMultimap<String, Property> source3 = ArrayListMultimap.create();
    source3.put(null, new DefaultProperty(new PropertyEntityDefinition(t, childContext3, SchemaSpaceID.SOURCE, null)));
    cell3.setSource(source3);
    ListMultimap<String, Property> target3 = ArrayListMultimap.create();
    target3.put(null, new DefaultProperty(new PropertyEntityDefinition(t, childContext3, SchemaSpaceID.TARGET, null)));
    cell3.setTarget(target3);
    baseAlignment.addCell(cell1);
    baseAlignment.addCell(cell2);
    String baseDisableCellId = cell2.getId();
    baseAlignment.addCell(cell3);
    String extendedDisableCellId = cell3.getId();
    assertEquals(3, baseAlignment.getCells().size());
    Cell typeCell = baseAlignment.getTypeCells().iterator().next();
    assertEquals(2, baseAlignment.getPropertyCells(typeCell).size());
    // test disable, it should not be with the related property cells
    cell2.setDisabledFor(cell1, true);
    assertEquals(1, baseAlignment.getPropertyCells(typeCell).size());
    assertTrue(cell2.getDisabledFor().contains(cell1.getId()));
    cell2.setDisabledFor(cell1, false);
    assertFalse(cell2.getDisabledFor().contains(cell1.getId()));
    cell2.setDisabledFor(cell1, true);
    assertEquals(1, baseAlignment.getPropertyCells(typeCell).size());
    // save base alignment
    File baseAlignmentFile = tmp.newFile("alignment_base.xml");
    System.out.println(baseAlignmentFile.getAbsolutePath());
    saveAlignment(baseAlignment, new BufferedOutputStream(new FileOutputStream(baseAlignmentFile)));
    // load base alignment
    MutableAlignment baseAlignment2 = loadAlignment(new FileInputStream(baseAlignmentFile), schema, schema);
    typeCell = baseAlignment2.getTypeCells().iterator().next();
    assertEquals(3, baseAlignment2.getCells().size());
    // test again that it is still disabled
    assertEquals(1, baseAlignment2.getPropertyCells(typeCell).size());
    // disable the remaining enabled cell in extended alignment
    addBaseAlignment(alignment, baseAlignmentFile.toURI(), schema, schema);
    assertEquals(1, alignment.getBaseAlignments().size());
    String usedPrefix = alignment.getBaseAlignments().keySet().iterator().next();
    File alignmentFile = tmp.newFile("alignment_extended.xml");
    // check cells
    typeCell = alignment.getTypeCells().iterator().next();
    assertEquals(3, alignment.getCells().size());
    assertEquals(1, alignment.getPropertyCells(typeCell).size());
    // disable remaining cell
    ((ModifiableCell) alignment.getPropertyCells(typeCell, false, false).iterator().next()).setDisabledFor(typeCell, true);
    assertEquals(0, alignment.getPropertyCells(typeCell).size());
    // save / load extended alignment
    System.out.println(alignmentFile.getAbsolutePath());
    saveAlignment(alignment, new BufferedOutputStream(new FileOutputStream(alignmentFile)));
    // load extended
    MutableAlignment alignment2 = loadAlignment(new FileInputStream(alignmentFile), schema, schema);
    typeCell = alignment2.getTypeCells().iterator().next();
    // test disabled again
    assertEquals(3, alignment2.getCells().size());
    // test again that it is still disabled
    assertEquals(0, alignment2.getPropertyCells(typeCell).size());
    // more specifically test whether the disables come from base alignment
    // or extended alignment
    Cell baseDisableCell = alignment2.getCell(usedPrefix + ":" + baseDisableCellId);
    Cell extendedDisableCell = alignment2.getCell(usedPrefix + ":" + extendedDisableCellId);
    assertTrue(baseDisableCell instanceof BaseAlignmentCell);
    assertEquals(1, baseDisableCell.getDisabledFor().size());
    assertEquals(1, ((BaseAlignmentCell) baseDisableCell).getBaseDisabledFor().size());
    assertEquals(0, ((BaseAlignmentCell) baseDisableCell).getAdditionalDisabledFor().size());
    assertTrue(extendedDisableCell instanceof BaseAlignmentCell);
    assertEquals(1, extendedDisableCell.getDisabledFor().size());
    assertEquals(0, ((BaseAlignmentCell) extendedDisableCell).getBaseDisabledFor().size());
    assertEquals(1, ((BaseAlignmentCell) extendedDisableCell).getAdditionalDisabledFor().size());
}
Also used : Schema(eu.esdihumboldt.hale.common.schema.model.Schema) DefaultSchema(eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchema) ArrayList(java.util.ArrayList) DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext) DefaultAlignment(eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment) Property(eu.esdihumboldt.hale.common.align.model.Property) DefaultProperty(eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) BaseAlignmentCell(eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell) Cell(eu.esdihumboldt.hale.common.align.model.Cell) ModifiableCell(eu.esdihumboldt.hale.common.align.model.ModifiableCell) MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) BufferedOutputStream(java.io.BufferedOutputStream) ModifiableCell(eu.esdihumboldt.hale.common.align.model.ModifiableCell) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) QName(javax.xml.namespace.QName) MutableAlignment(eu.esdihumboldt.hale.common.align.model.MutableAlignment) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) DefaultProperty(eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty) FileInputStream(java.io.FileInputStream) Type(eu.esdihumboldt.hale.common.align.model.Type) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) BaseAlignmentCell(eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Test(org.junit.Test)

Aggregations

DefaultType (eu.esdihumboldt.hale.common.align.model.impl.DefaultType)16 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)15 Type (eu.esdihumboldt.hale.common.align.model.Type)14 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)12 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)6 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)6 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)6 Cell (eu.esdihumboldt.hale.common.align.model.Cell)5 MutableAlignment (eu.esdihumboldt.hale.common.align.model.MutableAlignment)5 DefaultAlignment (eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)5 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)4 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)4 DefaultSchema (eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchema)4 DefaultTypeDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)4 BufferedOutputStream (java.io.BufferedOutputStream)4 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 FileOutputStream (java.io.FileOutputStream)4