use of org.eclipse.vorto.core.api.model.mapping.ReferenceTarget in project vorto by eclipse.
the class ModelDtoFactory method createResource.
public static Infomodel createResource(InformationModel model, Optional<MappingModel> mappingModel) {
Infomodel infoResource = new Infomodel(new ModelId(model.getName(), model.getNamespace(), model.getVersion()), ModelType.InformationModel);
for (FunctionblockProperty property : model.getProperties()) {
infoResource.getFunctionblocks().add(createProperty(property, mappingModel));
}
infoResource.setDescription(model.getDescription());
infoResource.setDisplayName(model.getDisplayname());
infoResource.setReferences(model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList()));
if (mappingModel.isPresent()) {
MappingModel _mappingModel = mappingModel.get();
infoResource.setTargetPlatformKey(_mappingModel.getTargetPlatform());
for (MappingRule rule : getInfoModelRule(_mappingModel.getRules())) {
if (rule.getTarget() instanceof StereoTypeTarget) {
StereoTypeTarget target = (StereoTypeTarget) rule.getTarget();
infoResource.addStereotype(Stereotype.create(target.getName(), convertAttributesToMap(target.getAttributes())));
} else if (rule.getTarget() instanceof ReferenceTarget) {
ReferenceTarget target = (ReferenceTarget) rule.getTarget();
infoResource.setMappingReference(createModelId(target.getMappingModel()));
}
}
}
return infoResource;
}
use of org.eclipse.vorto.core.api.model.mapping.ReferenceTarget in project vorto by eclipse.
the class ModelDtoFactory method createProperty.
private static ModelProperty createProperty(FunctionblockProperty property, Optional<MappingModel> mappingModel) {
ModelProperty p = new ModelProperty();
p.setDescription(property.getDescription());
p.setName(property.getName());
p.setType(createModelId(property.getType()));
if (mappingModel.isPresent()) {
p.setTargetPlatformKey(mappingModel.get().getTargetPlatform());
for (MappingRule rule : getPropertyRule(p.getName(), mappingModel.get().getRules())) {
if (rule.getTarget() instanceof StereoTypeTarget) {
StereoTypeTarget target = (StereoTypeTarget) rule.getTarget();
p.addStereotype(Stereotype.create(target.getName(), convertAttributesToMap(target.getAttributes())));
} else if (rule.getTarget() instanceof ReferenceTarget) {
ReferenceTarget target = (ReferenceTarget) rule.getTarget();
p.setMappingReference(createModelId(target.getMappingModel()));
}
}
}
return p;
}
use of org.eclipse.vorto.core.api.model.mapping.ReferenceTarget in project vorto by eclipse.
the class TestInfoModelMappingFactory method createReferenceTarget.
private static ReferenceTarget createReferenceTarget() {
ReferenceTarget referenceTarget = MappingFactory.eINSTANCE.createReferenceTarget();
referenceTarget.setMappingModel(null);
return referenceTarget;
}
Aggregations