Search in sources :

Example 1 with ReferenceTarget

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;
}
Also used : Infomodel(org.eclipse.vorto.repository.api.content.Infomodel) ReferenceTarget(org.eclipse.vorto.core.api.model.mapping.ReferenceTarget) 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) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel)

Example 2 with ReferenceTarget

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;
}
Also used : ReferenceTarget(org.eclipse.vorto.core.api.model.mapping.ReferenceTarget) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty) MappingRule(org.eclipse.vorto.core.api.model.mapping.MappingRule) StereoTypeTarget(org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget)

Example 3 with ReferenceTarget

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;
}
Also used : ReferenceTarget(org.eclipse.vorto.core.api.model.mapping.ReferenceTarget)

Aggregations

ReferenceTarget (org.eclipse.vorto.core.api.model.mapping.ReferenceTarget)3 MappingRule (org.eclipse.vorto.core.api.model.mapping.MappingRule)2 StereoTypeTarget (org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget)2 FunctionblockProperty (org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)1 MappingModel (org.eclipse.vorto.core.api.model.mapping.MappingModel)1 ModelId (org.eclipse.vorto.repository.api.ModelId)1 Infomodel (org.eclipse.vorto.repository.api.content.Infomodel)1 ModelProperty (org.eclipse.vorto.repository.api.content.ModelProperty)1