Search in sources :

Example 26 with AnnotationImpl

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;
}
Also used : AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition)

Example 27 with AnnotationImpl

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;
}
Also used : ValuePair(org.jboss.forge.roaster.model.ValuePair) AnnotationSource(org.jboss.forge.roaster.model.source.AnnotationSource) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition)

Example 28 with AnnotationImpl

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;
}
Also used : AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation)

Example 29 with AnnotationImpl

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;
}
Also used : AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) ClassAnnotation(org.kie.workbench.common.services.datamodeller.annotations.ClassAnnotation) EnumsAnnotation(org.kie.workbench.common.services.datamodeller.annotations.EnumsAnnotation) AnnotationValuesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation) PrimitivesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.PrimitivesAnnotation) TestAnnotation(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation) MarkerAnnotation(org.kie.workbench.common.services.datamodeller.annotations.MarkerAnnotation) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation)

Example 30 with AnnotationImpl

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();
    }
}
Also used : AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) Test(org.junit.Test)

Aggregations

AnnotationImpl (org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl)34 Annotation (org.kie.workbench.common.services.datamodeller.core.Annotation)24 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)11 Test (org.junit.Test)10 ObjectProperty (org.kie.workbench.common.services.datamodeller.core.ObjectProperty)10 DataModel (org.kie.workbench.common.services.datamodeller.core.DataModel)7 ObjectPropertyImpl (org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl)5 AnnotationDefinition (org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition)4 AnnotationValuePairDefinition (org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition)4 Entity (javax.persistence.Entity)2 Before (org.junit.Before)2 AnnotationDefinitionImpl (org.kie.workbench.common.services.datamodeller.core.impl.AnnotationDefinitionImpl)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Id (javax.persistence.Id)1 AnnotationMetaModel (org.drools.workbench.screens.factmodel.model.AnnotationMetaModel)1 Module (org.guvnor.common.services.project.model.Module)1 ValuePair (org.jboss.forge.roaster.model.ValuePair)1 AnnotationSource (org.jboss.forge.roaster.model.source.AnnotationSource)1