fixed loadProjectEdit method
This commit is contained in:
parent
55456b4040
commit
8eab316e70
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +36,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-module deploy-name="geoportal-data-viewer-app-3.0.0-SNAPSHOT">
|
<wb-module deploy-name="geoportal-data-viewer-app-3.0.0-SNAPSHOT">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +73,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,7 +110,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,7 +147,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,7 +184,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,7 +221,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,7 +258,8 @@
|
||||||
|
|
||||||
|
|
||||||
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -287,7 +295,8 @@
|
||||||
|
|
||||||
|
|
||||||
<property name="context-root" value="geoportal-data-viewer-app"/>
|
<property name="context-root" value="geoportal-data-viewer-app"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -323,7 +332,8 @@
|
||||||
|
|
||||||
|
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,16 +68,17 @@ public class Geoportal_JSON_Mapper {
|
||||||
public static final String JSON_$_POINTER = "$";
|
public static final String JSON_$_POINTER = "$";
|
||||||
|
|
||||||
public static final String _THEDOCUMENT = "_theDocument";
|
public static final String _THEDOCUMENT = "_theDocument";
|
||||||
|
|
||||||
public static ProjectEdit loadProjectEdit(ProjectDV theProjectDV, String scope, String username) throws Exception {
|
|
||||||
|
|
||||||
|
public static ProjectEdit loadProjectEdit(ProjectDV theProjectDV, String scope, String username) throws Exception {
|
||||||
|
LOG.debug("loadProjectEdit called");
|
||||||
|
|
||||||
String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
|
String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
|
||||||
|
|
||||||
LOG.debug("theProjectDV as JSON: " + theWholeProjectAsJSON);
|
LOG.debug("theProjectDV as JSON: " + theWholeProjectAsJSON);
|
||||||
LOG.debug("theProjectDV as MAP: " + theProjectDV.getTheDocument().getDocumentAsMap());
|
LOG.trace("theProjectDV as MAP: " + theProjectDV.getTheDocument().getDocumentAsMap());
|
||||||
|
|
||||||
ProjectEdit projectView = new ProjectEdit();
|
ProjectEdit projectEdit = new ProjectEdit();
|
||||||
projectView.setTheProjectDV(theProjectDV);
|
projectEdit.setTheProjectDV(theProjectDV);
|
||||||
|
|
||||||
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
|
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
|
||||||
.get(scope);
|
.get(scope);
|
||||||
|
@ -112,19 +113,14 @@ public class Geoportal_JSON_Mapper {
|
||||||
|
|
||||||
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
||||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||||
|
|
||||||
//LinkedHashMap<Integer, MetaDataProfileBeanExt> mapOfProfilesBeanExt = new LinkedHashMap<Integer, MetaDataProfileBeanExt>();
|
List<MetaDataProfileBeanExt> listOfProfilesBeanExt = new ArrayList<MetaDataProfileBeanExt>();
|
||||||
|
|
||||||
ArrayList<MetaDataProfileBeanExt> listOfProfilesBeanExt = new ArrayList<MetaDataProfileBeanExt>();
|
|
||||||
|
|
||||||
// Reading the Project according to list of Profile defined in the UCD
|
// Reading the Project according to list of Profile defined in the UCD
|
||||||
for (GcubeProfilesMetadataForUCD gcubeProfileMetaForUCD : listProfilesBean) {
|
for (GcubeProfilesMetadataForUCD gcubeProfileMetaForUCD : listProfilesBean) {
|
||||||
|
|
||||||
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
|
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
|
||||||
// SectionView sectionView = new SectionView();
|
LOG.debug("\n\n##### Creating the section: " + gcubeProfileDV.getSectionTitle());
|
||||||
// sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
|
|
||||||
|
|
||||||
System.out.println("\n\n##### Sto creando la sezione: "+gcubeProfileDV.getSectionTitle());
|
|
||||||
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
|
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
|
||||||
// Building JSON/section full PATH and section name
|
// Building JSON/section full PATH and section name
|
||||||
String sectionJSONPath = "";
|
String sectionJSONPath = "";
|
||||||
|
@ -178,80 +174,64 @@ public class Geoportal_JSON_Mapper {
|
||||||
LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
|
LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
|
||||||
List<MetaDataProfileBean> theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
|
List<MetaDataProfileBean> theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
|
||||||
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
|
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
|
||||||
|
|
||||||
|
|
||||||
// For each bson.Document filling the MetaDataProfileBean and its file
|
// For each bson.Document filling the MetaDataProfileBean and its file
|
||||||
for (int i = 0; i < listBSONDocument.size(); i++) {
|
for (int i = 0; i < listBSONDocument.size(); i++) {
|
||||||
|
|
||||||
System.out.println("DOCUMENT number "+i+ " of the section: "+theProfileBean.getTitle());
|
LOG.trace("DOCUMENT number " + i + " of the section: " + theProfileBean.getTitle());
|
||||||
MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
|
MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
|
||||||
theProfileBeanExt.setCategories(theProfileBean.getCategories());
|
theProfileBeanExt.setCategories(theProfileBean.getCategories());
|
||||||
theProfileBeanExt.setTitle(theProfileBean.getTitle());
|
theProfileBeanExt.setTitle(theProfileBean.getTitle());
|
||||||
theProfileBeanExt.setType(theProfileBean.getType());
|
theProfileBeanExt.setType(theProfileBean.getType());
|
||||||
|
|
||||||
// System.out.println("\nPRINTING PROJECT VIEW ON START: ");
|
|
||||||
// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
|
|
||||||
// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
|
|
||||||
// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
|
|
||||||
// int z = 0;
|
|
||||||
// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
|
|
||||||
// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
Document fromSectionDoc = listBSONDocument.get(i);
|
|
||||||
LOG.debug("\n\nNew section DOC for index " + i + " is: " + new JSONObject(fromSectionDoc.toJson()).toString(2));
|
|
||||||
//Creating the corresponding MetaDataProfileBeanExt for each section
|
|
||||||
|
|
||||||
//Reading policy and license statically
|
Document fromSectionDoc = listBSONDocument.get(i);
|
||||||
//eg. "_access":{"_policy":"OPEN","_license":"CC0-1.0"}}
|
LOG.debug("\n\nNew section DOC for index " + i + " is: "
|
||||||
|
+ new JSONObject(fromSectionDoc.toJson()).toString(2));
|
||||||
|
// Creating the corresponding MetaDataProfileBeanExt for each section
|
||||||
|
|
||||||
|
// Reading policy and license statically
|
||||||
|
// eg. "_access":{"_policy":"OPEN","_license":"CC0-1.0"}}
|
||||||
Document docAccess = null;
|
Document docAccess = null;
|
||||||
Access access = null;
|
Access access = null;
|
||||||
try {
|
try {
|
||||||
docAccess = fromSectionDoc.get("_access", Document.class);
|
docAccess = fromSectionDoc.get("_access", Document.class);
|
||||||
System.out.println("docAccess is: "+docAccess);
|
LOG.trace("docAccess is: " + docAccess);
|
||||||
access = new Access();
|
access = new Access();
|
||||||
access.setPolicy(AccessPolicy.valueOf(docAccess.getString("_policy")));
|
access.setPolicy(AccessPolicy.valueOf(docAccess.getString("_policy")));
|
||||||
access.setLicense(docAccess.getString("_license"));
|
access.setLicense(docAccess.getString("_license"));
|
||||||
// Access. access.get("_policy");
|
// Access. access.get("_policy");
|
||||||
// access.get("_license");
|
// access.get("_license");
|
||||||
System.out.println("access is: "+access);
|
System.out.println("access is: " + access);
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
LOG.warn("No " + AccessPolicy.class.getSimpleName() + "found in the section "
|
||||||
|
+ fromSectionDoc.toJson());
|
||||||
|
LOG.debug("No AccessPolicy.class.getSimpleName(): ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//List<MetadataFieldWrapper> copyOfMetadataFields = new ArrayList<MetadataFieldWrapper>(theProfileBean.getMetadataFields());
|
|
||||||
//int forIndex = 0;
|
|
||||||
|
|
||||||
List<MetadataFieldWrapper> cloneListOfMFW = cloneList(theProfileBean.getMetadataFields());
|
List<MetadataFieldWrapper> cloneListOfMFW = cloneList(theProfileBean.getMetadataFields());
|
||||||
|
|
||||||
for (MetadataFieldWrapper metadataField : cloneListOfMFW) {
|
for (MetadataFieldWrapper metadataField : cloneListOfMFW) {
|
||||||
|
|
||||||
String theFieldName = metadataField.getFieldId() != null ? metadataField.getFieldId()
|
String theFieldName = metadataField.getFieldId() != null ? metadataField.getFieldId()
|
||||||
: metadataField.getFieldName();
|
: metadataField.getFieldName();
|
||||||
LOG.debug("reading theFieldName: " + theFieldName);
|
LOG.debug("reading theFieldName: " + theFieldName);
|
||||||
Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
|
Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
|
||||||
metadataField.setCurrentValue(theOBJFieldValue+"");
|
metadataField.setCurrentValue(theOBJFieldValue + "");
|
||||||
|
|
||||||
if(access!=null) {
|
if (access != null) {
|
||||||
if(theFieldName.equalsIgnoreCase("policy")) {
|
if (theFieldName.equalsIgnoreCase("policy")) {
|
||||||
metadataField.setCurrentValue(access.getPolicy().name());
|
metadataField.setCurrentValue(access.getPolicy().name());
|
||||||
}else if(theFieldName.equalsIgnoreCase("licenseID")) {
|
} else if (theFieldName.equalsIgnoreCase("licenseID")) {
|
||||||
metadataField.setCurrentValue(access.getLicense());
|
metadataField.setCurrentValue(access.getLicense());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//copyOfMetadataFields.set(forIndex++, metadataField);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Before assigning it Metadata fields are: "+cloneListOfMFW);
|
|
||||||
|
|
||||||
theProfileBeanExt.setMetadataFields(new ArrayList<MetadataFieldWrapper>(cloneListOfMFW));
|
theProfileBeanExt.setMetadataFields(new ArrayList<MetadataFieldWrapper>(cloneListOfMFW));
|
||||||
LOG.debug("Metadata fields are: "+theProfileBeanExt.getMetadataFields());
|
LOG.debug("Metadata fields are: " + theProfileBeanExt.getMetadataFields());
|
||||||
|
|
||||||
// Reading filePaths
|
// Reading filePaths
|
||||||
List<FilePathDV> filePaths = gcubeProfileDV.getFilePaths();
|
List<FilePathDV> filePaths = gcubeProfileDV.getFilePaths();
|
||||||
List<GCubeSDIViewerLayerDV> listLayers = new ArrayList<GCubeSDIViewerLayerDV>();
|
|
||||||
|
|
||||||
// READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
|
// READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
|
||||||
if (filePaths != null) {
|
if (filePaths != null) {
|
||||||
|
@ -268,42 +248,25 @@ public class Geoportal_JSON_Mapper {
|
||||||
for (Payload payload : listPayloads) {
|
for (Payload payload : listPayloads) {
|
||||||
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
|
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
|
||||||
filesetDV.addPayloadDV(payloadDV);
|
filesetDV.addPayloadDV(payloadDV);
|
||||||
listFiles.add(filesetDV);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reading Fileset _materializations
|
listFiles.add(filesetDV);
|
||||||
//listLayers = readGcubeSDILayersForFileset(filesetJSONPath, fromSectionDocJSON);
|
|
||||||
//theProfileBeanExt.set
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
theProfileBeanExt.setListFileset(listFiles);
|
theProfileBeanExt.setListFileset(listFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("\nputting theProfileBeanExt: "+theProfileBeanExt);
|
LOG.trace("\nputting theProfileBeanExt: " + theProfileBeanExt);
|
||||||
listOfProfilesBeanExt.add(theProfileBeanExt);
|
listOfProfilesBeanExt.add(theProfileBeanExt);
|
||||||
|
|
||||||
// System.out.println("\nPRINTING PROJECT VIEW ON END: ");
|
|
||||||
// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
|
|
||||||
// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
|
|
||||||
// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
|
|
||||||
// int z = 0;
|
|
||||||
// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
|
|
||||||
// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// System.out.println(listProfileBeansExt.get(listProfileBeansExt.size()-1));
|
|
||||||
//Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
projectView.setTheProfileBeans(listOfProfilesBeanExt);
|
|
||||||
|
|
||||||
//Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
|
projectEdit.setTheProfileBeans(listOfProfilesBeanExt);
|
||||||
|
|
||||||
return projectView;
|
LOG.info("returning ProjectEdit with " + projectEdit.getTheProfileBeans().size() + " profile beans");
|
||||||
|
|
||||||
|
return projectEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<MetadataFieldWrapper> cloneList(List<MetadataFieldWrapper> list) {
|
public static List<MetadataFieldWrapper> cloneList(List<MetadataFieldWrapper> list) {
|
||||||
|
@ -583,8 +546,8 @@ public class Geoportal_JSON_Mapper {
|
||||||
LOG.trace("The _payloads is a String {}", toStringPayloads);
|
LOG.trace("The _payloads is a String {}", toStringPayloads);
|
||||||
JSONArray jsonArray = new JSONArray(toStringPayloads);
|
JSONArray jsonArray = new JSONArray(toStringPayloads);
|
||||||
for (int i = 0; i < jsonArray.length(); i++) {
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
Payload payloadDV = Serialization.read(jsonArray.getJSONObject(i).toString(), Payload.class);
|
Payload payload = Serialization.read(jsonArray.getJSONObject(i).toString(), Payload.class);
|
||||||
listPayloads.add(payloadDV);
|
listPayloads.add(payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,8 +925,15 @@ public class Geoportal_JSON_Mapper {
|
||||||
i = 1;
|
i = 1;
|
||||||
System.out.println("***** Files");
|
System.out.println("***** Files");
|
||||||
for (FilesetDV fileSet : mpb.getListFileset()) {
|
for (FilesetDV fileSet : mpb.getListFileset()) {
|
||||||
System.out.println("## " + FilesetDV.class.getSimpleName() + " n." + i);
|
System.out.println(
|
||||||
System.out.println(fileSet);
|
"## " + FilesetDV.class.getSimpleName() + " n." + i + " has name: " + fileSet.getName());
|
||||||
|
|
||||||
|
if (fileSet.getListPayload() != null) {
|
||||||
|
int j = 0;
|
||||||
|
for (PayloadDV payload : fileSet.getListPayload()) {
|
||||||
|
System.out.println("\t" + ++j + ") " + payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class GeoportalViewer_Tests {
|
||||||
//private static String TOKEN = ""; // devVRE
|
//private static String TOKEN = ""; // devVRE
|
||||||
|
|
||||||
private static String PROFILE_ID = "profiledConcessioni";
|
private static String PROFILE_ID = "profiledConcessioni";
|
||||||
private static String PROJECT_ID = "637ceb4d21dd0d6fb9f24706";
|
private static String PROJECT_ID = "6384c56c308f5c28c5ee0986";
|
||||||
|
|
||||||
private static String USERNAME = "francesco.mangiacrapa";
|
private static String USERNAME = "francesco.mangiacrapa";
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class GeoportalViewer_Tests {
|
||||||
*
|
*
|
||||||
* @return the client
|
* @return the client
|
||||||
*/
|
*/
|
||||||
//@Before
|
@Before
|
||||||
public void getClient() {
|
public void getClient() {
|
||||||
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||||
ScopeProvider.instance.set(CONTEXT);
|
ScopeProvider.instance.set(CONTEXT);
|
||||||
|
@ -235,7 +235,7 @@ public class GeoportalViewer_Tests {
|
||||||
|
|
||||||
// ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, CONTEXT, USERNAME);
|
// ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, CONTEXT, USERNAME);
|
||||||
// Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
|
// Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
|
||||||
System.out.println("testReadProjectEdit terminated");
|
System.out.println("\n\n testReadProjectEdit terminated!!!");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Error");
|
System.err.println("Error");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in New Issue