Search in sources :

Example 16 with MappingRule

use of org.eclipse.vorto.core.api.model.mapping.MappingRule in project vorto by eclipse.

the class MappingModelSyntaxTest method parseMappingWithEntityAttribute.

@Test
public void parseMappingWithEntityAttribute() throws IOException {
    MappingModel mappingModel = createMappingModel("type/Entity_Attribute.mapping");
    EList<MappingRule> rules = mappingModel.getRules();
    assertEquals(3, rules.size());
}
Also used : MappingRule(org.eclipse.vorto.core.api.model.mapping.MappingRule) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel) Test(org.junit.Test)

Example 17 with MappingRule

use of org.eclipse.vorto.core.api.model.mapping.MappingRule in project vorto by eclipse.

the class MappingModelSyntaxTest method parseMappingWithEnumProperty.

@Test
public void parseMappingWithEnumProperty() throws IOException {
    MappingModel mappingModel = createMappingModel("type/Enum_Property.mapping");
    EList<MappingRule> rules = mappingModel.getRules();
    assertEquals(2, rules.size());
}
Also used : MappingRule(org.eclipse.vorto.core.api.model.mapping.MappingRule) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel) Test(org.junit.Test)

Example 18 with MappingRule

use of org.eclipse.vorto.core.api.model.mapping.MappingRule in project vorto by eclipse.

the class MappingModelSyntaxTest method parseMappingWithInfomodelReference.

@Test
public void parseMappingWithInfomodelReference() throws IOException {
    MappingModel mappingModel = createMappingModel("Infomodel_FBRef.mapping");
    EList<MappingRule> rules = mappingModel.getRules();
    assertEquals(1, rules.size());
}
Also used : MappingRule(org.eclipse.vorto.core.api.model.mapping.MappingRule) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel) Test(org.junit.Test)

Example 19 with MappingRule

use of org.eclipse.vorto.core.api.model.mapping.MappingRule in project vorto by eclipse.

the class MappingModelSyntaxTest method parseMappingWithFunctionBlockAttribute.

@Test
public void parseMappingWithFunctionBlockAttribute() throws IOException {
    MappingModel mappingModel = createMappingModel("fb/FunctionBlock_Attribute.mapping");
    EList<MappingRule> rules = mappingModel.getRules();
    assertEquals(6, rules.size());
}
Also used : MappingRule(org.eclipse.vorto.core.api.model.mapping.MappingRule) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel) Test(org.junit.Test)

Example 20 with MappingRule

use of org.eclipse.vorto.core.api.model.mapping.MappingRule in project vorto by eclipse.

the class ModelDtoFactory method createResource.

public static org.eclipse.vorto.repository.api.content.FunctionblockModel createResource(FunctionblockModel model, Optional<MappingModel> mappingModel) {
    org.eclipse.vorto.repository.api.content.FunctionblockModel resource = new org.eclipse.vorto.repository.api.content.FunctionblockModel(new ModelId(model.getName(), model.getNamespace(), model.getVersion()), ModelType.Functionblock);
    resource.setDescription(model.getDescription());
    resource.setDisplayName(model.getDisplayname());
    resource.setReferences(model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList()));
    if (model.getFunctionblock().getConfiguration() != null) {
        resource.setConfigurationProperties(model.getFunctionblock().getConfiguration().getProperties().stream().map(p -> createProperty(p, mappingModel)).collect(Collectors.toList()));
    }
    if (model.getFunctionblock().getStatus() != null) {
        resource.setStatusProperties(model.getFunctionblock().getStatus().getProperties().stream().map(p -> createProperty(p, mappingModel)).collect(Collectors.toList()));
    }
    if (model.getFunctionblock().getFault() != null) {
        resource.setFaultProperties(model.getFunctionblock().getFault().getProperties().stream().map(p -> createProperty(p, mappingModel)).collect(Collectors.toList()));
    }
    if (model.getFunctionblock().getEvents() != null) {
        resource.setEvents(model.getFunctionblock().getEvents().stream().map(e -> createEvent(e, mappingModel)).collect(Collectors.toList()));
    }
    if (model.getFunctionblock().getOperations() != null) {
        resource.setOperations(model.getFunctionblock().getOperations().stream().map(o -> createOperation(o)).collect(Collectors.toList()));
    }
    if (mappingModel.isPresent()) {
        MappingModel _mappingModel = mappingModel.get();
        resource.setTargetPlatformKey(_mappingModel.getTargetPlatform());
        for (MappingRule rule : getFbRule(_mappingModel.getRules())) {
            StereoTypeTarget target = (StereoTypeTarget) rule.getTarget();
            resource.addStereotype(Stereotype.create(target.getName(), convertAttributesToMap(target.getAttributes())));
        }
    }
    return resource;
}
Also used : FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) MappingRule(org.eclipse.vorto.core.api.model.mapping.MappingRule) StereoTypeTarget(org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget) ModelId(org.eclipse.vorto.repository.api.ModelId) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel)

Aggregations

MappingRule (org.eclipse.vorto.core.api.model.mapping.MappingRule)20 MappingModel (org.eclipse.vorto.core.api.model.mapping.MappingModel)18 Test (org.junit.Test)14 StereoTypeTarget (org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget)6 ModelId (org.eclipse.vorto.repository.api.ModelId)5 ReferenceTarget (org.eclipse.vorto.core.api.model.mapping.ReferenceTarget)3 Optional (java.util.Optional)2 FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)2 FunctionblockProperty (org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)2 Attribute (org.eclipse.vorto.core.api.model.mapping.Attribute)2 EntityModel (org.eclipse.vorto.repository.api.content.EntityModel)2 Infomodel (org.eclipse.vorto.repository.api.content.Infomodel)2 ModelProperty (org.eclipse.vorto.repository.api.content.ModelProperty)2 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 BooleanPropertyAttribute (org.eclipse.vorto.core.api.model.datatype.BooleanPropertyAttribute)1 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)1 Enum (org.eclipse.vorto.core.api.model.datatype.Enum)1 EnumLiteralPropertyAttribute (org.eclipse.vorto.core.api.model.datatype.EnumLiteralPropertyAttribute)1