Skip to content

Commit

Permalink
MID-9278 more code removed from dom to schema post processor
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Nov 3, 2023
1 parent 388306d commit 5a16026
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,55 @@
*/
public enum Annotation {

IGNORE(A_IGNORE, ItemProcessing.class, null, new IgnoreProcessor()),

PROCESSING(A_PROCESSING, ItemProcessing.class, null, new ItemProcessingProcessor()),

DEPRECATED(A_DEPRECATED, Boolean.class, true),

DEPRECATED_SINCE(A_DEPRECATED_SINCE, String.class),

REMOVED(A_REMOVED, Boolean.class, true),
DISPLAY_NAME(A_DISPLAY_NAME, String.class),

REMOVED_SINCE(A_REMOVED_SINCE, String.class),
DISPLAY_ORDER(A_DISPLAY_ORDER, Integer.class),

EXPERIMENTAL(A_EXPERIMENTAL, Boolean.class, true),
DOCUMENTATION(DOMUtil.XSD_DOCUMENTATION_ELEMENT, String.class, null, new AnnotationProcessor() {

PLANNED_REMOVAL(A_PLANNED_REMOVAL, String.class),
@Override
protected @Nullable Object convert(@NotNull Annotation annotation, @NotNull Element element) {
return DOMUtil.serializeElementContent(element);
}
}),

ELABORATE(A_ELABORATE, Boolean.class, true),

OPERATIONAL(A_OPERATIONAL, Boolean.class, true),

DISPLAY_NAME(A_DISPLAY_NAME, String.class),
EMPHASIZED(A_EMPHASIZED, Boolean.class, true),

DISPLAY_ORDER(A_DISPLAY_ORDER, Integer.class),
EXPERIMENTAL(A_EXPERIMENTAL, Boolean.class, true),

HELP(A_HELP, String.class),

EMPHASIZED(A_EMPHASIZED, Boolean.class, true),
HETEROGENEOUS_LIST_ITEM(A_HETEROGENEOUS_LIST_ITEM, Boolean.class, true),

SEARCHABLE(A_SEARCHABLE, Boolean.class, true),
IGNORE(A_IGNORE, ItemProcessing.class, null, new IgnoreProcessor()),

DOCUMENTATION(DOMUtil.XSD_DOCUMENTATION_ELEMENT, String.class, null, new AnnotationProcessor() {
OBJECT_REFERENCE_TARGET_TYPE(A_OBJECT_REFERENCE_TARGET_TYPE, QName.class, null, new AnnotationProcessor() {

@Override
protected @Nullable Object convert(@NotNull Annotation annotation, @NotNull Element element) {
return DOMUtil.serializeElementContent(element);
return DOMUtil.getQNameValue(element);
}
}),

HETEROGENEOUS_LIST_ITEM(A_HETEROGENEOUS_LIST_ITEM, Boolean.class, true),
OPERATIONAL(A_OPERATIONAL, Boolean.class, true),

// todo schema migration
PLANNED_REMOVAL(A_PLANNED_REMOVAL, String.class),

// todo diagrams?
PROCESSING(A_PROCESSING, ItemProcessing.class, null, new ItemProcessingProcessor()),

OBJECT_REFERENCE_TARGET_TYPE(A_OBJECT_REFERENCE_TARGET_TYPE, QName.class, null, new AnnotationProcessor() {
REMOVED(A_REMOVED, Boolean.class, true),

protected @Nullable Object convert(@NotNull Annotation annotation, @NotNull Element element) {
return DOMUtil.getQNameValue(element);
}
});
REMOVED_SINCE(A_REMOVED_SINCE, String.class),

SEARCHABLE(A_SEARCHABLE, Boolean.class, true);

// todo schema migration
// todo diagrams?
// todo others?

final QName name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,6 @@ private void extractDocumentation(Definition definition, XSAnnotation annotation
}

Annotation.processAnnotation(definition.toMutable(), annotation, Annotation.DOCUMENTATION);

Element documentationElement = SchemaProcessorUtil.getAnnotationElement(annotation, DOMUtil.XSD_DOCUMENTATION_ELEMENT);
if (documentationElement != null) {
// The documentation may be HTML-formatted. Therefore we want to
// keep the formatting and tag names
String documentationText = DOMUtil.serializeElementContent(documentationElement);
definition.toMutable().setDocumentation(documentationText);
}
}

/**
Expand Down Expand Up @@ -1119,19 +1111,9 @@ private void parseItemDefinitionAnnotations(MutableItemDefinition itemDef, XSAnn

Annotation.processAnnotations(itemDef, annotation);

Boolean searchable = SchemaProcessorUtil.getAnnotationBooleanMarker(annotation, A_SEARCHABLE);
if (searchable != null) {
itemDef.setSearchable(searchable);
}

// documentation
extractDocumentation(itemDef, annotation);

Boolean heterogeneousListItem = SchemaProcessorUtil.getAnnotationBooleanMarker(annotation, A_HETEROGENEOUS_LIST_ITEM);
if (heterogeneousListItem != null) {
itemDef.setHeterogeneousListItem(heterogeneousListItem);
}

// schemaMigration
parseSchemaMigrations(itemDef, annotation);

Expand Down

0 comments on commit 5a16026

Please sign in to comment.