Added projectId to DocumentDV

This commit is contained in:
Francesco Mangiacrapa 2022-10-12 15:23:01 +02:00
parent e8a52bcf7e
commit 40eb373fa7
2 changed files with 28 additions and 12 deletions

View File

@ -509,7 +509,7 @@ public class ConvertToDataValueObjectModel {
project.getProfileVersion() != null ? project.getProfileVersion().getValue() : ""); project.getProfileVersion() != null ? project.getProfileVersion().getValue() : "");
theProject.setVersion(project.getVersion() != null ? project.getVersion().getValue() : ""); theProject.setVersion(project.getVersion() != null ? project.getVersion().getValue() : "");
theProject.setTheDocument(toGenericDocumentDV(project.getTheDocument(), DocumentDV.class, theProject.setTheDocument(toGenericDocumentDV(project.getId(), project.getTheDocument(), DocumentDV.class,
projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap())); projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
List<Relationship> relations = project.getRelationships(); List<Relationship> relations = project.getRelationships();
@ -531,8 +531,9 @@ public class ConvertToDataValueObjectModel {
identificationReferences.size()); identificationReferences.size());
for (IdentificationReference identificationReference : identificationReferences) { for (IdentificationReference identificationReference : identificationReferences) {
IdentificationReferenceDV idv = toIdentificationReferenceDV(identificationReference, IdentificationReferenceDV idv = toIdentificationReferenceDV(project.getId(),
projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()); identificationReference, projectReader.getListDocumentKeys(),
projectReader.isIncludeFullDocumentMap());
mapIdentReferenceDV.put(idv.getType(), idv); mapIdentReferenceDV.put(idv.getType(), idv);
} }
@ -588,7 +589,7 @@ public class ConvertToDataValueObjectModel {
try { try {
ResultDocumentDV rd = (ResultDocumentDV) toGenericDocumentDV(project.getTheDocument(), ResultDocumentDV rd = (ResultDocumentDV) toGenericDocumentDV(project.getId(), project.getTheDocument(),
ResultDocumentDV.class, null, true); ResultDocumentDV.class, null, true);
rd.setId(project.getId()); rd.setId(project.getId());
rd.setProfileID(project.getProfileID()); rd.setProfileID(project.getProfileID());
@ -684,18 +685,19 @@ public class ConvertToDataValueObjectModel {
/** /**
* To identification reference DV. * To identification reference DV.
* *
* @param projectID the project ID
* @param identificationReference the identification reference * @param identificationReference the identification reference
* @param listDocumentKeys the list document keys * @param listDocumentKeys the list document keys
* @param getFullMap the get full map * @param getFullMap the get full map
* @return the identification reference DV * @return the identification reference DV
*/ */
private static IdentificationReferenceDV toIdentificationReferenceDV( private static IdentificationReferenceDV toIdentificationReferenceDV(String projectID,
IdentificationReference identificationReference, List<String> listDocumentKeys, boolean getFullMap) { IdentificationReference identificationReference, List<String> listDocumentKeys, boolean getFullMap) {
if (identificationReference == null) if (identificationReference == null)
return null; return null;
IdentificationReferenceDV idv = (IdentificationReferenceDV) toGenericDocumentDV(identificationReference, IdentificationReferenceDV idv = (IdentificationReferenceDV) toGenericDocumentDV(projectID,
IdentificationReferenceDV.class, listDocumentKeys, getFullMap); identificationReference, IdentificationReferenceDV.class, listDocumentKeys, getFullMap);
idv.setType(identificationReference.getType()); idv.setType(identificationReference.getType());
return idv; return idv;
@ -771,14 +773,15 @@ public class ConvertToDataValueObjectModel {
* To generic document DV. * To generic document DV.
* *
* @param <T> the generic type * @param <T> the generic type
* @param projectID the project ID
* @param document the document * @param document the document
* @param targetClass the target class * @param targetClass the target class
* @param listDocumentKeys the list document keys * @param listDocumentKeys the list document keys
* @param getFullMap the get full map * @param getFullMap the get full map
* @return the document DV * @return the document DV
*/ */
public static <T extends DocumentDV> DocumentDV toGenericDocumentDV(Document document, Class<T> targetClass, public static <T extends DocumentDV> DocumentDV toGenericDocumentDV(String projectID, Document document,
List<String> listDocumentKeys, boolean getFullMap) { Class<T> targetClass, List<String> listDocumentKeys, boolean getFullMap) {
if (document == null) if (document == null)
return null; return null;
@ -819,6 +822,7 @@ public class ConvertToDataValueObjectModel {
} }
documentDV.setDocumentAsJSON(document.toJson()); documentDV.setDocumentAsJSON(document.toJson());
documentDV.setProjectID(projectID);
return documentDV; return documentDV;
} }

View File

@ -14,21 +14,31 @@ public class DocumentDV implements Serializable {
private String documentAsJSON; private String documentAsJSON;
private ConfigurationDV<?> configuration; private ConfigurationDV<?> configuration;
private String projectID;
public DocumentDV() { public DocumentDV() {
} }
public LinkedHashMap<String, Object> getDocumentAsMap() { public LinkedHashMap<String, Object> getDocumentAsMap() {
return documentAsMap; return documentAsMap;
} }
public Entry<String, Object> getFirstEntryOfMap() { public Entry<String, Object> getFirstEntryOfMap() {
if(documentAsMap!=null && documentAsMap.size()>1) { if (documentAsMap != null && documentAsMap.size() > 1) {
return documentAsMap.entrySet().iterator().next(); return documentAsMap.entrySet().iterator().next();
} }
return null; return null;
} }
public String getProjectID() {
return projectID;
}
public void setProjectID(String projectID) {
this.projectID = projectID;
}
public String getDocumentAsJSON() { public String getDocumentAsJSON() {
return documentAsJSON; return documentAsJSON;
} }
@ -58,6 +68,8 @@ public class DocumentDV implements Serializable {
builder.append(documentAsJSON); builder.append(documentAsJSON);
builder.append(", configuration="); builder.append(", configuration=");
builder.append(configuration); builder.append(configuration);
builder.append(", projectID=");
builder.append(projectID);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }