Skip to content
Merged
Show file tree
Hide file tree
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 @@ -143,6 +143,7 @@ private static String getBaseDirectory(NewPlugin plugin) {

public static Class<? extends Customization> loadCustomizationClassFromJavaCode(String filePath,
String baseDirectory, Logger logger) {
final Path originCustomizationFile = Paths.get(filePath);
Path customizationFile = Paths.get(filePath);
if (!customizationFile.isAbsolute()) {
if (baseDirectory != null) {
Expand All @@ -155,7 +156,7 @@ public static Class<? extends Customization> loadCustomizationClassFromJavaCode(
return loadCustomizationClass(customizationFile.getFileName().toString().replace(".java", ""), code);
} catch (IOException e) {
logger.error("Cannot read customization from base directory {} and file {}", baseDirectory,
customizationFile);
originCustomizationFile);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum ResourceType {
PROXY_RESOURCE(ResourceTypeName.PROXY_RESOURCE),
SUB_RESOURCE(ResourceTypeName.SUB_RESOURCE);

private String className;
private final String className;

ResourceType(String className) {
this.className = className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public CodeModel process(CodeModel codeModel) {
Optional<ObjectSchema> parentType = getObjectParent(compositeType);
if (parentType.isPresent()) {
getSchemaResourceType(parentType.get()).ifPresent(type -> {
renameSchemaOnResourceType(parentType.get(), type);
correctDeduplicatedName(parentType.get());
adaptForParentSchema(compositeType, parentType.get(), type);
});

Expand Down Expand Up @@ -270,24 +270,16 @@ private static Optional<ResourceType> getSchemaResourceType(ObjectSchema composi
}

/**
* Rename the schema based on the resource type.
* Correct the schema name based on the resource type.
*
* @param compositeType the object schema to rename
* @param type the resource type
* @param compositeType the object schema to correct
*/
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 correctDeduplicatedName(ObjectSchema compositeType) {
final String deduplicateSuffix = "AutoGenerated";
final String javaName = Utils.getJavaName(compositeType);
if (javaName.contains(deduplicateSuffix)) {
int index = javaName.indexOf(deduplicateSuffix);
compositeType.getLanguage().getJava().setName(javaName.substring(0, index));
}
}

Expand Down
Loading