use of org.eclipse.vorto.core.api.model.mapping.Attribute in project vorto by eclipse.
the class TestStereoTypeFactory method createStereoTypeTarget.
public static StereoTypeTarget createStereoTypeTarget() {
StereoTypeTarget stereoType = MappingFactory.eINSTANCE.createStereoTypeTarget();
Attribute typeAttribute = MappingFactory.eINSTANCE.createAttribute();
typeAttribute.setName("DummyAttribute");
typeAttribute.setValue("Dummy Attribute Value");
stereoType.setName("DummyStereoType");
stereoType.getAttributes().add(typeAttribute);
return stereoType;
}
use of org.eclipse.vorto.core.api.model.mapping.Attribute in project vorto by eclipse.
the class DefaultResolver method doResolve.
@Override
protected ModelId doResolve(ModelInfo mappingModelResource, ResolveQuery query) {
IModelContent content = this.repository.getModelContent(mappingModelResource.getId(), ContentType.DSL);
MappingModel mappingModel = (MappingModel) content.getModel();
Optional<MappingRule> objectRule = mappingModel.getRules().stream().filter(rule -> rule.getTarget() instanceof StereoTypeTarget && ((StereoTypeTarget) rule.getTarget()).getName().equals(query.getStereoType())).findFirst();
if (objectRule.isPresent()) {
Optional<Attribute> objectIdAttribute = ((StereoTypeTarget) objectRule.get().getTarget()).getAttributes().stream().filter(attribute -> attribute.getName().equals(query.getAttributeId())).findFirst();
if (objectIdAttribute.isPresent() && objectIdAttribute.get().getValue().equals(query.getAttributeValue())) {
return ModelId.fromReference(mappingModel.getReferences().get(0).getImportedNamespace(), mappingModel.getReferences().get(0).getVersion());
}
}
return null;
}
Aggregations