use of org.eclipse.vorto.repository.api.content.EntityModel in project vorto by eclipse.
the class ModelDtoFactory method createResource.
public static EntityModel createResource(Entity model, Optional<MappingModel> mappingModel) {
EntityModel resource = new EntityModel(new ModelId(model.getName(), model.getNamespace(), model.getVersion()), ModelType.Datatype);
resource.setDescription(model.getDescription());
resource.setDisplayName(model.getDisplayname());
resource.setReferences(model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList()));
resource.setProperties(model.getProperties().stream().map(p -> createProperty(p, mappingModel)).collect(Collectors.toList()));
if (mappingModel.isPresent()) {
resource.setTargetPlatformKey(mappingModel.get().getTargetPlatform());
for (MappingRule rule : getEntityRule(mappingModel.get().getRules())) {
StereoTypeTarget target = (StereoTypeTarget) rule.getTarget();
resource.addStereotype(Stereotype.create(target.getName(), convertAttributesToMap(target.getAttributes())));
}
}
return resource;
}
use of org.eclipse.vorto.repository.api.content.EntityModel in project vorto by eclipse.
the class DefaultMappingClient method newPropertyQuery.
@Override
public IMappingQuery<ModelProperty> newPropertyQuery(IMappedElement element) {
final List<ModelProperty> properties = new ArrayList<ModelProperty>();
if (element instanceof FunctionblockModel) {
FunctionblockModel fbm = (FunctionblockModel) element;
properties.addAll(fbm.getConfigurationProperties());
properties.addAll(fbm.getStatusProperties());
properties.addAll(fbm.getFaultProperties());
} else if (element instanceof Infomodel) {
Infomodel im = (Infomodel) element;
properties.addAll(im.getFunctionblocks());
} else if (element instanceof EntityModel) {
EntityModel entity = (EntityModel) element;
properties.addAll(entity.getProperties());
} else {
throw new UnsupportedOperationException();
}
return new MappingQueryJxPath<ModelProperty>() {
@Override
protected Collection<ModelProperty> getAll() {
return properties;
}
};
}
Aggregations