Search in sources :

Example 1 with EntityModel

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;
}
Also used : EntityModel(org.eclipse.vorto.repository.api.content.EntityModel) 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)

Example 2 with EntityModel

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;
        }
    };
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) Infomodel(org.eclipse.vorto.repository.api.content.Infomodel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty) ArrayList(java.util.ArrayList) EntityModel(org.eclipse.vorto.repository.api.content.EntityModel)

Aggregations

EntityModel (org.eclipse.vorto.repository.api.content.EntityModel)2 ArrayList (java.util.ArrayList)1 MappingRule (org.eclipse.vorto.core.api.model.mapping.MappingRule)1 StereoTypeTarget (org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget)1 ModelId (org.eclipse.vorto.repository.api.ModelId)1 FunctionblockModel (org.eclipse.vorto.repository.api.content.FunctionblockModel)1 Infomodel (org.eclipse.vorto.repository.api.content.Infomodel)1 ModelProperty (org.eclipse.vorto.repository.api.content.ModelProperty)1