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());
}
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());
}
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());
}
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());
}
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;
}
Aggregations