use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class DefaultDataModelOracleAnnotationDriver method buildAnnotation.
@Override
public Annotation buildAnnotation(AnnotationDefinition annotationDefinition, Object annotationToken) throws ModelDriverException {
org.kie.soup.project.datamodel.oracle.Annotation oracleAnnotationToken = (org.kie.soup.project.datamodel.oracle.Annotation) annotationToken;
AnnotationImpl annotation = new AnnotationImpl(annotationDefinition);
if (annotationDefinition.isMarker()) {
return annotation;
} else if (oracleAnnotationToken.getParameters() != null) {
Object currentAttributeValue;
for (AnnotationValuePairDefinition annotationMember : annotationDefinition.getValuePairs()) {
currentAttributeValue = oracleAnnotationToken.getParameters().get(annotationMember.getName());
if (currentAttributeValue != null) {
annotation.setValue(annotationMember.getName(), currentAttributeValue);
}
}
}
return annotation;
}
use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class DefaultJavaRoasterModelAnnotationDriver method buildAnnotation.
@Override
public Annotation buildAnnotation(AnnotationDefinition annotationDefinition, Object annotationToken) throws ModelDriverException {
AnnotationSource javaAnnotationToken = (AnnotationSource) annotationToken;
AnnotationImpl annotation = new AnnotationImpl(annotationDefinition);
if (annotationDefinition.isMarker()) {
return annotation;
} else {
if (javaAnnotationToken.getValues() != null) {
List<ValuePair> values = javaAnnotationToken.getValues();
if (values != null && values.size() > 0) {
for (AnnotationValuePairDefinition valuePairDefinition : annotationDefinition.getValuePairs()) {
Object annotationValue = buildAnnotationValue(javaAnnotationToken, valuePairDefinition);
if (annotationValue != null) {
annotation.setValue(valuePairDefinition.getName(), annotationValue);
}
}
}
}
}
return annotation;
}
use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class DataModelerEditorsTestHelper method createAnnotation.
public static Annotation createAnnotation(Class cls, String memberName, Object value) {
AnnotationDefinition annotationDefinition = DriverUtils.buildAnnotationDefinition(cls);
Annotation annotation = new AnnotationImpl(annotationDefinition);
if (memberName != null) {
annotation.setValue(memberName, value);
}
return annotation;
}
use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriverTest method createAnnotation.
private Annotation createAnnotation(Class cls, String memberName, Object value) {
AnnotationDefinition annotationDefinition = DriverUtils.buildAnnotationDefinition(cls);
Annotation annotation = new AnnotationImpl(annotationDefinition);
if (memberName != null) {
annotation.setValue(memberName, value);
}
return annotation;
}
use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testClassAnnotationStringGeneration.
@Test
public void testClassAnnotationStringGeneration() {
Annotation classReactive = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.ClassReactive.class.getName()));
Annotation propReactive = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.PropertyReactive.class.getName()));
Annotation role = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.Role.class.getName()));
role.setValue("value", org.kie.api.definition.type.Role.Type.EVENT.name());
GenerationContext generationContext = new GenerationContext(dataModelOracleDriver.createModel());
try {
String result = engine.generateAnnotationString(generationContext, classReactive);
assertEquals(results.getProperty("testClassAnnotationStringGeneration1"), result);
result = engine.generateAnnotationString(generationContext, propReactive);
assertEquals(results.getProperty("testClassAnnotationStringGeneration2"), result);
result = engine.generateAnnotationString(generationContext, role);
assertEquals(results.getProperty("testClassAnnotationStringGeneration3"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations