use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.
the class AnnotationListItem method loadAnnotation.
public void loadAnnotation(Annotation annotation, AnnotationSource annotationSource) {
this.annotation = annotation;
view.setHeadingTitle(annotation.getClassName());
if (annotation.getAnnotationDefinition() != null && annotation.getAnnotationDefinition().getValuePairs() != null) {
for (AnnotationValuePairDefinition valuePairDefinition : annotation.getAnnotationDefinition().getValuePairs()) {
AnnotationValuePairListItem valuePairListItem = createListItem();
valuePairListItem.loadValuePair(annotation, valuePairDefinition, annotationSource);
valuePairListItem.setClearValuePairHandler(new AdvancedAnnotationListEditorView.ClearValuePairHandler() {
@Override
public void onClearValuePair(Annotation annotation, String valuePair) {
if (clearValuePairHandler != null) {
clearValuePairHandler.onClearValuePair(annotation, valuePair);
}
}
});
valuePairListItem.setEditValuePairHandler(new AdvancedAnnotationListEditorView.EditValuePairHandler() {
@Override
public void onEditValuePair(Annotation annotation, String valuePair) {
if (editValuePairHandler != null) {
editValuePairHandler.onEditValuePair(annotation, valuePair);
}
}
});
view.addItem(valuePairListItem);
items.add(valuePairListItem);
}
}
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.
the class GenerationTools method resolveAnnotationType.
public String resolveAnnotationType(Annotation annotation) {
StringBuffer type = new StringBuffer();
AnnotationDefinition annotationDefinition = annotation.getAnnotationDefinition();
if (annotationDefinition == null) {
logger.warn("Annotation definition for annotation: " + annotation + " is not defined.");
return type.toString();
}
if (annotationDefinition.isMarker()) {
return type.toString();
}
// finally we can process annotation members.
Object memberValue;
int memberCount = 0;
for (AnnotationValuePairDefinition memberDefinition : annotationDefinition.getValuePairs()) {
if ((memberValue = annotation.getValue(memberDefinition.getName())) != null) {
// a value has been set for this member.
if (memberCount == 0) {
type.append("(");
}
if (memberCount > 0) {
type.append(", ");
}
type.append(resolveMemberType(memberDefinition, memberValue));
memberCount++;
}
}
if (memberCount > 0) {
type.append(")");
}
return type.toString();
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition 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.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.
the class DefaultJavaModelAnnotationDriver method buildAnnotation.
@Override
public Annotation buildAnnotation(AnnotationDefinition annotationDefinition, Object annotationToken) throws ModelDriverException {
AnnotationDescr javaAnnotationToken = (AnnotationDescr) annotationToken;
AnnotationImpl annotation = new AnnotationImpl(annotationDefinition);
if (annotationDefinition.isMarker()) {
return annotation;
} else {
// try to read annotation parameters
if (javaAnnotationToken.hasElementValue()) {
for (AnnotationValuePairDefinition annotationMember : annotationDefinition.getValuePairs()) {
if ("value".equals(annotationMember.getName())) {
annotation.setValue(annotationMember.getName(), parseParamValue(annotationDefinition, annotationMember.getName(), javaAnnotationToken.getElementValue().getValue()));
}
}
} else if (javaAnnotationToken.hasElementValuePairs()) {
ElementValuePairListDescr valuePairListDescr = javaAnnotationToken.getElementValuePairs();
if (valuePairListDescr != null && valuePairListDescr.getValuePairs() != null) {
Map<String, ElementValueDescr> valuePairValues = new HashMap<String, ElementValueDescr>();
for (ElementValuePairDescr valuePair : valuePairListDescr.getValuePairs()) {
valuePairValues.put(valuePair.getIdentifier().getIdentifier(), valuePair.getValue());
}
for (AnnotationValuePairDefinition annotationMember : annotationDefinition.getValuePairs()) {
ElementValueDescr value = valuePairValues.get(annotationMember.getName());
if (value != null) {
annotation.setValue(annotationMember.getName(), parseParamValue(annotationDefinition, annotationMember.getName(), value.getValue()));
}
}
}
}
}
return annotation;
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition 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;
}
Aggregations