Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ public CodeModel process(CodeModel codeModel) {
objectSchemas.forEach(compositeType -> {
Optional<ObjectSchema> parentType = getObjectParent(compositeType);
if (parentType.isPresent()) {
getSchemaResourceType(parentType.get())
.ifPresent(type -> adaptForParentSchema(compositeType, parentType.get(), type));
getSchemaResourceType(parentType.get()).ifPresent(type -> {
renameSchemaOnResourceType(parentType.get(), type);
adaptForParentSchema(compositeType, parentType.get(), type);
});

if (FluentType.SYSTEM_DATA.getName().equals(Utils.getJavaName(parentType.get()))) {
adaptAsSystemData(compositeType);
Expand Down Expand Up @@ -231,6 +233,12 @@ private static void adaptAsSystemData(ObjectSchema compositeType) {
}
}

/**
* Check the object schema, determine its resource type.
*
* @param compositeType the object schema to check
* @return the resource type
*/
private static Optional<ResourceType> getSchemaResourceType(ObjectSchema compositeType) {
ResourceType type = null;

Expand Down Expand Up @@ -261,6 +269,28 @@ private static Optional<ResourceType> getSchemaResourceType(ObjectSchema composi
return Optional.ofNullable(type);
}

/**
* Rename the schema based on the resource type.
*
* @param compositeType the object schema to rename
* @param type the resource type
*/
private static void renameSchemaOnResourceType(ObjectSchema compositeType, ResourceType type) {
switch (type) {
case SUB_RESOURCE:
compositeType.getLanguage().getJava().setName(ResourceTypeName.SUB_RESOURCE);
break;

case PROXY_RESOURCE:
compositeType.getLanguage().getJava().setName(ResourceTypeName.PROXY_RESOURCE);
break;

case RESOURCE:
compositeType.getLanguage().getJava().setName(ResourceTypeName.RESOURCE);
break;
}
}

private static void adaptForParentSchema(ObjectSchema compositeType, ObjectSchema parentType, ResourceType type) {
switch (type) {
case SUB_RESOURCE: {
Expand Down
Loading