Skip to content

#164: Add payloads and simple data type to reference metadata and report #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
65 changes: 26 additions & 39 deletions src/main/java/org/reso/certification/codegen/EDMXProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.apache.logging.log4j.Logger;
import org.reso.commander.common.Utils;
import org.reso.models.ReferenceStandardField;
import org.reso.models.ReferenceStandardLookup;
import org.w3c.dom.Document;
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.w3c.dom.ls.DOMImplementationLS;
Expand All @@ -20,7 +19,6 @@
import java.util.Map;

import static org.reso.commander.common.DataDictionaryMetadata.getKeyFieldForResource;
import static org.reso.commander.common.Utils.wrapColumns;

//TODO: switch to build an XML document rather than creating it as a string
public class EDMXProcessor extends WorksheetProcessor {
Expand Down Expand Up @@ -115,7 +113,8 @@ void processExpansion(ReferenceStandardField field) {

content.append(EDMXTemplates.buildDisplayNameAnnotation(field.getDisplayName()))
.append(EDMXTemplates.buildDDWikiUrlAnnotation(field.getWikiPageUrl()))
.append(EDMXTemplates.buildDescriptionAnnotation(field.getDefinition()));
.append(EDMXTemplates.buildDescriptionAnnotation(field.getDefinition()))
.append(EDMXTemplates.buildPayloadsAnnotation(String.join(",", field.getPayloads())));

content.append("</NavigationProperty>");

Expand Down Expand Up @@ -276,38 +275,43 @@ private String buildMultipleEnumTypeMarkup(ReferenceStandardField standardField)

public static final class EDMXTemplates {
public static String buildDisplayNameAnnotation(String content) {
if (content == null || content.length() == 0) return EMPTY_STRING;
if (content == null || content.isEmpty()) return EMPTY_STRING;
return String.format("<Annotation Term=\"RESO.OData.Metadata.StandardName\" String=\"%1$s\" />", sanitizeXml(content));
}

public static String buildPayloadsAnnotation(String content) {
if (content == null || content.isEmpty()) return EMPTY_STRING;
return String.format("<Annotation Term=\"RESO.OData.Metadata.Payloads\" String=\"%1$s\" />", sanitizeXml(content));
}

//wrapColumns(referenceStandardField.getDefinition().replaceAll("--", "-"), " ")
public static String buildDescriptionAnnotation(String content) {
if (content == null || content.length() == 0) return EMPTY_STRING;
if (content == null || content.isEmpty()) return EMPTY_STRING;
return String.format("<Annotation Term=\"Core.Description\" String=\"%1$s\" />", sanitizeXml(content));
}

public static String buildDDWikiUrlAnnotation(String content) {
if (content == null || content.length() == 0) return EMPTY_STRING;
if (content == null || content.isEmpty()) return EMPTY_STRING;
return String.format("<Annotation Term=\"RESO.DDWikiUrl\" String=\"%1$s\" />", sanitizeXml(content));
}

public static String buildBooleanMember(ReferenceStandardField field) {
if (field == null) return EMPTY_STRING;
return ""
+ "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.Boolean\" >"
return "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.Boolean\" >"
+ buildDisplayNameAnnotation(field.getDisplayName())
+ buildDDWikiUrlAnnotation(field.getWikiPageUrl())
+ buildDescriptionAnnotation(field.getDefinition())
+ buildPayloadsAnnotation(String.join(",", field.getPayloads()))
+ "</Property>";
}

public static String buildDateMember(ReferenceStandardField field) {
if (field == null) return EMPTY_STRING;
return ""
+ "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.Date\" >"
return "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.Date\" >"
+ buildDisplayNameAnnotation(field.getDisplayName())
+ buildDDWikiUrlAnnotation(field.getWikiPageUrl())
+ buildDescriptionAnnotation(field.getDefinition())
+ buildPayloadsAnnotation(String.join(",", field.getPayloads()))
+ "</Property>";
}

Expand All @@ -319,8 +323,7 @@ public static String buildNumberMember(ReferenceStandardField field) {

public static String buildDecimalMember(ReferenceStandardField field) {
if (field == null) return EMPTY_STRING;
String template = ""
+ "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.Decimal\"";
String template = "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.Decimal\"";

//DD uses length as precision in this case
if (field.getSuggestedMaxLength() != null) template += " Precision=\"" + field.getSuggestedMaxLength() + "\"";
Expand All @@ -332,52 +335,54 @@ public static String buildDecimalMember(ReferenceStandardField field) {
+ buildDisplayNameAnnotation(field.getDisplayName())
+ buildDDWikiUrlAnnotation(field.getWikiPageUrl())
+ buildDescriptionAnnotation(field.getDefinition())
+ buildPayloadsAnnotation(String.join(",", field.getPayloads()))
+ "</Property>";

return template;
}

public static String buildIntegerMember(ReferenceStandardField field) {
if (field == null) return EMPTY_STRING;
return ""
+ "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.Int64\" >"
return "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.Int64\" >"
+ buildDisplayNameAnnotation(field.getDisplayName())
+ buildDDWikiUrlAnnotation(field.getWikiPageUrl())
+ buildDescriptionAnnotation(field.getDefinition())
+ buildPayloadsAnnotation(String.join(",", field.getPayloads()))
+ "</Property>";
}

public static String buildEnumTypeSingleMember(ReferenceStandardField field) {
if (field == null || field.getLookupName() == null) return EMPTY_STRING;
if (field.getLookupName().trim().length() == 0) return EMPTY_STRING;
if (field.getLookupName().trim().isEmpty()) return EMPTY_STRING;

return
"<Property Name=\"" + field.getStandardName()
+ "\" Type=\"" + RESO_NAMESPACE + ".enums." + field.getLookupName() + "\" >"
+ buildDisplayNameAnnotation(field.getDisplayName())
+ buildDDWikiUrlAnnotation(field.getWikiPageUrl())
+ buildDescriptionAnnotation(field.getDefinition())
+ buildPayloadsAnnotation(String.join(",", field.getPayloads()))
+ "</Property>";
}

public static String buildEnumTypeMultiMember(ReferenceStandardField field) {
if (field == null || field.getLookupName() == null) return EMPTY_STRING;
if (field.getLookupName().trim().length() == 0) return EMPTY_STRING;
if (field.getLookupName().trim().isEmpty()) return EMPTY_STRING;

return
"<Property Name=\"" + field.getStandardName()
+ "\" Type=\"Collection(" + RESO_NAMESPACE + ".enums." + field.getLookupName() + ")\">"
+ buildDisplayNameAnnotation(field.getDisplayName())
+ buildDDWikiUrlAnnotation(field.getWikiPageUrl())
+ buildDescriptionAnnotation(field.getDefinition())
+ buildPayloadsAnnotation(String.join(",", field.getPayloads()))
+ "</Property>";

}

public static String buildStringMember(ReferenceStandardField field) {
if (field == null) return EMPTY_STRING;
String template = ""
+ "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.String\"";
String template = "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.String\"";

if (field.getSuggestedMaxLength() != null) template += " MaxLength=\"" + field.getSuggestedMaxLength() + "\"";
template += " >";
Expand All @@ -386,15 +391,15 @@ public static String buildStringMember(ReferenceStandardField field) {
buildDisplayNameAnnotation(field.getDisplayName())
+ buildDDWikiUrlAnnotation(field.getWikiPageUrl())
+ buildDescriptionAnnotation(field.getDefinition())
+ buildPayloadsAnnotation(String.join(",", field.getPayloads()))
+ "</Property>";

return template;
}

public static String buildDateTimeWithOffsetMember(ReferenceStandardField field) {
if (field == null) return EMPTY_STRING;
String template = ""
+ "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.DateTimeOffset\"";
String template = "<Property Name=\"" + field.getStandardName() + "\" Type=\"Edm.DateTimeOffset\"";

if (field.getSuggestedMaxLength() != null) template += " Precision=\"" + field.getSuggestedMaxLength() + "\"";
template += " >";
Expand All @@ -403,28 +408,10 @@ public static String buildDateTimeWithOffsetMember(ReferenceStandardField field)
buildDisplayNameAnnotation(field.getDisplayName())
+ buildDDWikiUrlAnnotation(field.getWikiPageUrl())
+ buildDescriptionAnnotation(field.getDefinition())
+ buildPayloadsAnnotation(String.join(",", field.getPayloads()))
+ "</Property>";
return template;
}

public static String buildComments(ReferenceStandardField referenceStandardField) {
if (referenceStandardField == null || referenceStandardField.getDefinition() == null || referenceStandardField.getDefinition().length() == 0)
return EMPTY_STRING;

//break every COLUMN_WIDTH characters only at word boundaries
return (referenceStandardField.getWikiPageUrl() != null && referenceStandardField.getWikiPageUrl().length() > 0 ?
" <!-- " + referenceStandardField.getWikiPageUrl() : "")
+ " -->";
}

public static String buildComments(ReferenceStandardLookup referenceStandardLookup) {
if (referenceStandardLookup == null || referenceStandardLookup.getDefinition() == null || referenceStandardLookup.getDefinition().length() == 0)
return EMPTY_STRING;

//break every COLUMN_WIDTH characters only at word boundaries
return (referenceStandardLookup.getWikiPageUrl() != null && referenceStandardLookup.getWikiPageUrl().length() > 0 ? " <!-- " + referenceStandardLookup.getWikiPageUrl() : "") +
wrapColumns(referenceStandardLookup.getDefinition().replaceAll("--", "-"), " ")
+ " -->";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: ContactListingNotes

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: ContactListings

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Contacts

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Field

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: HistoryTransactional

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: InternetTracking

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Lookup

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Media

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Member

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Office

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: OpenHouse

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: OtherPhone

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: OUID

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Property

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: PropertyGreenVerification

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: PropertyPowerProduction

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: PropertyRooms

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: PropertyUnitTypes

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Prospecting

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Queue

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Rules

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: SavedSearch

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Showing

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: SocialMedia

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: TeamMembers

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108150315330
# This file was autogenerated on: 2023110900245888
Feature: Teams

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108152427929
# This file was autogenerated on: 20231109002504917
Feature: Association

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108152427929
# This file was autogenerated on: 20231109002504917
Feature: Caravan

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108152427929
# This file was autogenerated on: 20231109002504917
Feature: CaravanStop

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108152427929
# This file was autogenerated on: 20231109002504917
Feature: ContactListingNotes

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108152427929
# This file was autogenerated on: 20231109002504917
Feature: ContactListings

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108152427929
# This file was autogenerated on: 20231109002504917
Feature: Contacts

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated on: 20231108152427929
# This file was autogenerated on: 20231109002504917
Feature: EntityEvent

Background:
Expand Down
Loading