use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class GenerationEngineTest method setup.
@Before
public void setup() {
try {
InputStream in = this.getClass().getResourceAsStream("GenerationTestResults.properties");
results.load(in);
in.close();
Set<String> propertyNames = results.stringPropertyNames();
for (String property : propertyNames) {
String newProperty = results.getProperty(property).replaceAll("\n", System.getProperty("line.separator"));
results.setProperty(property, newProperty);
}
engine = GenerationEngine.getInstance();
dataModelOracleDriver = DataModelOracleModelDriver.getInstance();
annotationDefinitions = new HashMap<String, AnnotationDefinition>(5);
List<AnnotationDefinition> configuredAnnotations = dataModelOracleDriver.getConfiguredAnnotations();
for (AnnotationDefinition annotationDefinition : configuredAnnotations) {
annotationDefinitions.put(annotationDefinition.getClassName(), annotationDefinition);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriver method resolveAnnotationSource.
public org.kie.workbench.common.services.datamodeller.driver.model.AnnotationSource resolveAnnotationSource(Annotation annotation) {
org.kie.workbench.common.services.datamodeller.driver.model.AnnotationSource annotationSource = new org.kie.workbench.common.services.datamodeller.driver.model.AnnotationSource();
// TODO this method can be optimized and likely migrated to Roaster. Should be reviewed when we evaluate
// the removal of Velocity.
GenerationTools generationTools = new GenerationTools();
AnnotationDefinition annotationDefinition;
StringBuilder annotationCode = new StringBuilder();
annotationCode.append("@");
annotationCode.append(annotation.getClassName());
if ((annotationDefinition = annotation.getAnnotationDefinition()) != null) {
if (!annotationDefinition.isMarker()) {
annotationCode.append(generationTools.resolveAnnotationType(annotation));
}
if (annotationDefinition.getValuePairs() != null) {
Object value;
String valuePairCode;
for (AnnotationValuePairDefinition valuePairDefinition : annotationDefinition.getValuePairs()) {
if ((value = annotation.getValue(valuePairDefinition.getName())) != null) {
valuePairCode = generationTools.resolveMemberTypeExpression(valuePairDefinition, value);
} else {
valuePairCode = null;
}
annotationSource.withValuePairSource(valuePairDefinition.getName(), valuePairCode);
}
}
}
annotationSource.withSource(annotationCode.toString());
return annotationSource;
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class DataModelOracleModelDriver method createAnnotation.
private org.kie.workbench.common.services.datamodeller.core.Annotation createAnnotation(Annotation annotationToken) throws ModelDriverException {
AnnotationDefinition annotationDefinition = getConfiguredAnnotation(annotationToken.getQualifiedTypeName());
org.kie.workbench.common.services.datamodeller.core.Annotation annotation = null;
if (annotationDefinition != null) {
AnnotationDriver annotationDriver = getAnnotationDriver(annotationDefinition.getClassName());
if (annotationDriver != null) {
annotation = annotationDriver.buildAnnotation(annotationDefinition, annotationToken);
} else {
logger.warn("AnnotationDriver for annotation: " + annotationToken.getQualifiedTypeName() + " is not configured for this driver");
}
} else {
logger.warn("Annotation: " + annotationToken.getQualifiedTypeName() + " is not configured for this driver.");
}
return annotation;
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class DataModelerServiceImpl method getAnnotationDefinitions.
@Override
public Map<String, AnnotationDefinition> getAnnotationDefinitions() {
Map<String, AnnotationDefinition> annotations = new HashMap<String, AnnotationDefinition>();
// add additional annotations configured by external domains
Iterator<DomainHandler> it = domainHandlers != null ? domainHandlers.iterator() : null;
DomainHandler domainHandler;
List<List<AnnotationDefinition>> allDomainsAnnotations = new ArrayList<List<AnnotationDefinition>>();
while (it != null && it.hasNext()) {
domainHandler = it.next();
allDomainsAnnotations.add(domainHandler.getManagedAnnotations());
}
List<AnnotationDefinition> coreAnnotationDefinitions = (new JavaRoasterModelDriver()).getConfiguredAnnotations();
allDomainsAnnotations.add(coreAnnotationDefinitions);
for (List<AnnotationDefinition> annotationDefinitionList : allDomainsAnnotations) {
if (annotationDefinitionList != null) {
for (AnnotationDefinition annotationDefinition : annotationDefinitionList) {
annotations.put(annotationDefinition.getClassName(), annotationDefinition);
}
}
}
return annotations;
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class DataModelTestUtil method createAnnotation.
public Annotation createAnnotation(Map<String, AnnotationDefinition> systemAnnotations, String className, String memberName, Object value) {
AnnotationDefinition annotationDefinition = systemAnnotations.get(className);
Annotation annotation = new AnnotationImpl(annotationDefinition);
if (memberName != null) {
annotation.setValue(memberName, value);
}
return annotation;
}
Aggregations