Added Expand Button into View Relations Panel
This commit is contained in:
parent
f576b0f966
commit
c34faa9f68
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -51,7 +52,8 @@
|
|||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-3.0.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -103,7 +105,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -155,7 +158,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -207,20 +211,16 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="metadata-profile-form-builder-widget-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-form-builder-widget/metadata-profile-form-builder-widget">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module archiveName="metadata-profile-discovery-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-discovery/metadata-profile-discovery">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module archiveName="geoportal-data-common-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -272,7 +272,8 @@
|
|||
|
||||
|
||||
<property name="context-root" value="geoportal-data-entry-app"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -324,7 +325,8 @@
|
|||
|
||||
|
||||
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -376,7 +378,8 @@
|
|||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -46,17 +46,6 @@ public class ConstantsGeoPortalDataEntryApp {
|
|||
|
||||
public static final String WORKFLOW_ACTION_POST_CREATION_ACTION_ID = "post_creation_action";
|
||||
|
||||
// /**
|
||||
// * The Enum RECORD_TYPE.
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
// *
|
||||
// * Aug 6, 2021
|
||||
// */
|
||||
// public enum RECORD_TYPE {
|
||||
// CONCESSIONE
|
||||
// }
|
||||
|
||||
/**
|
||||
* The Enum ACTION_PERFORMED_ON_ITEM.
|
||||
*
|
||||
|
|
|
@ -656,7 +656,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
if (!bool) {
|
||||
return;
|
||||
}
|
||||
viewRelationshipPanel = new ViewRelationshipPanel(appManagerBus, selectedDocument);
|
||||
viewRelationshipPanel = new ViewRelationshipPanel(appManagerBus, selectedDocument, true);
|
||||
detailsPanel.add(viewRelationshipPanel);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
|||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Label;
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconSize;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
|
@ -24,6 +25,7 @@ import com.google.gwt.event.dom.client.ClickHandler;
|
|||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
|
@ -59,13 +61,16 @@ public class ViewRelationshipPanel extends Composite {
|
|||
@UiField
|
||||
Button closeButton;
|
||||
|
||||
@UiField
|
||||
Button buttonExpand;
|
||||
|
||||
private HashMap<Integer, ResultDocumentDV> selectedProjects = new HashMap<Integer, ResultDocumentDV>(2);
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
|
||||
private Map<String, ResultDocumentDV> mapOfTargetProjectForId = new HashMap<String, ResultDocumentDV>();
|
||||
|
||||
public ViewRelationshipPanel(HandlerManager appManagerBus, ResultDocumentDV fromProject) {
|
||||
public ViewRelationshipPanel(HandlerManager appManagerBus, ResultDocumentDV fromProject, boolean showExpand) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.appManagerBus = appManagerBus;
|
||||
|
||||
|
@ -81,6 +86,34 @@ public class ViewRelationshipPanel extends Composite {
|
|||
}
|
||||
});
|
||||
|
||||
buttonExpand.setType(ButtonType.LINK);
|
||||
buttonExpand.setIcon(IconType.EXPAND);
|
||||
buttonExpand.setTitle("Show this view in new Window");
|
||||
buttonExpand.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Modal mw = new Modal(true, true);
|
||||
mw.setTitle("Relationships");
|
||||
|
||||
int width = Window.getClientWidth();
|
||||
if(width > 1024) {
|
||||
width = 1024;
|
||||
mw.setWidth(width);
|
||||
}
|
||||
mw.add(new ViewRelationshipPanel(appManagerBus, fromProject, false));
|
||||
mw.show();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (!showExpand) {
|
||||
buttonExpand.setVisible(false);
|
||||
panelTitle.setVisible(false);
|
||||
closeButton.setVisible(false);
|
||||
}
|
||||
|
||||
showRelationsOf(fromProject);
|
||||
}
|
||||
|
||||
|
@ -89,8 +122,8 @@ public class ViewRelationshipPanel extends Composite {
|
|||
secondProjectPanelContainer.clear();
|
||||
|
||||
Entry<String, Object> firstEntrySet = project.getFirstEntryOfMap();
|
||||
String htmlMsg = firstEntrySet.getKey() + ": <b>" + firstEntrySet.getValue()
|
||||
+ "</b> (id: " + project.getId() + ")";
|
||||
String htmlMsg = firstEntrySet.getKey() + ": <b>" + firstEntrySet.getValue() + "</b> (id: " + project.getId()
|
||||
+ ")";
|
||||
|
||||
firstProjectPanelContainer.add(new HTML(htmlMsg));
|
||||
ReportTemplateToHTML rtth = new ReportTemplateToHTML("", project.getDocumentAsJSON(), false, false);
|
||||
|
@ -105,37 +138,35 @@ public class ViewRelationshipPanel extends Composite {
|
|||
secondProjectPanelContainer.clear();
|
||||
|
||||
for (RelationshipDV relationDV : project.getListRelationshipDV()) {
|
||||
|
||||
|
||||
final FlexTable flexTable = new FlexTable();
|
||||
flexTable.getElement().addClassName("box-table-diplay-project");
|
||||
Label label = new Label();
|
||||
label.setType(LabelType.INFO);
|
||||
label.setText(relationDV.getRelationshipName());
|
||||
|
||||
|
||||
|
||||
FlowPanel panelContainer = new FlowPanel();
|
||||
Button deleteRelation = new Button("",IconType.TRASH);
|
||||
Button deleteRelation = new Button("", IconType.TRASH);
|
||||
deleteRelation.setTitle("Delete this releation");
|
||||
deleteRelation.setType(ButtonType.LINK);
|
||||
deleteRelation.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ResultDocumentDV toProject = mapOfTargetProjectForId.get(relationDV.getTargetUCD());
|
||||
appManagerBus.fireEvent(new RelationActionHandlerEvent(project, relationDV.getRelationshipName(), toProject));
|
||||
|
||||
appManagerBus.fireEvent(
|
||||
new RelationActionHandlerEvent(project, relationDV.getRelationshipName(), toProject));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
panelContainer.add(label);
|
||||
panelContainer.add(deleteRelation);
|
||||
flexTable.setWidget(0, 0, panelContainer);
|
||||
|
||||
|
||||
|
||||
flexTable.setWidget(1, 0, new LoaderIcon("loading project.."));
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().getResultDocumentFoProjectByID(relationDV.getTargetUCD(),
|
||||
relationDV.getTargetID(), new AsyncCallback<ResultDocumentDV>() {
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().getResultDocumentFoProjectByID(
|
||||
relationDV.getTargetUCD(), relationDV.getTargetID(), new AsyncCallback<ResultDocumentDV>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -149,17 +180,17 @@ public class ViewRelationshipPanel extends Composite {
|
|||
Entry<String, Object> firstEntrySet = result.getFirstEntryOfMap();
|
||||
String htmlMsg = firstEntrySet.getKey() + ": <b>" + firstEntrySet.getValue()
|
||||
+ "</b> (id: " + result.getId() + ")";
|
||||
|
||||
|
||||
flexTable.setWidget(1, 0, new HTML(htmlMsg));
|
||||
|
||||
ReportTemplateToHTML rtth2 = new ReportTemplateToHTML("", result.getDocumentAsJSON(), false, false);
|
||||
|
||||
ReportTemplateToHTML rtth2 = new ReportTemplateToHTML("", result.getDocumentAsJSON(),
|
||||
false, false);
|
||||
rtth2.showAsJSON(false);
|
||||
|
||||
flexTable.setWidget(2, 0, rtth2);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
secondProjectPanelContainer.add(flexTable);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
padding-left: 10px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.float-right {
|
||||
float: right;
|
||||
}
|
||||
</ui:style>
|
||||
|
||||
<g:HTMLPanel>
|
||||
|
@ -41,6 +45,8 @@
|
|||
addStyleNames="{style.to-align-right}"></b:Button>
|
||||
<g:HTMLPanel ui:field="panelTitle"
|
||||
addStyleNames="{style.view-rel-title}">View Relations</g:HTMLPanel>
|
||||
<b:Button ui:field="buttonExpand"
|
||||
addStyleNames="{style.float-right}">Expand</b:Button>
|
||||
<g:HTMLPanel ui:field="firstPanelContainer"
|
||||
addStyleNames="{style.panel-style}">
|
||||
<g:FlowPanel>
|
||||
|
@ -48,7 +54,6 @@
|
|||
</g:FlowPanel>
|
||||
<g:FlowPanel ui:field="firstProjectPanelContainer"
|
||||
addStyleNames="{style.panel-container-style}"></g:FlowPanel>
|
||||
|
||||
</g:HTMLPanel>
|
||||
<g:HTMLPanel ui:field="secondPanelContainer"
|
||||
addStyleNames="{style.panel-style}">
|
||||
|
|
|
@ -136,30 +136,6 @@ public class ReportTemplateToHTML extends Composite {
|
|||
GWT.log("report is: " + theJSONDocument);
|
||||
vpContainer.setVisible(true);
|
||||
|
||||
// try {
|
||||
// JSONValue jsonObj = JSONParser.parse(theJSONDocument);
|
||||
// JSONObject json = (JSONObject) jsonObj;
|
||||
// JSONValue valueChildren = json.get("children");
|
||||
// JSONArray jsonChildren = (JSONArray) valueChildren;
|
||||
//
|
||||
// String toTableHTML = null;
|
||||
// for (int i = 0; i < jsonChildren.size(); i++) {
|
||||
// JSONObject jsO = (JSONObject) jsonChildren.get(i);
|
||||
//
|
||||
// if (jsO.containsKey("children")) {
|
||||
// toTableHTML = jsonToHTML(jsO.get("children").toString());
|
||||
// } else {
|
||||
// toTableHTML = jsonToHTML(jsO.toString());
|
||||
// }
|
||||
//
|
||||
// htmlContainer.add(new HTML(toTableHTML));
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// GWT.log("error: " + e.getMessage());
|
||||
// }
|
||||
|
||||
try {
|
||||
|
||||
JSONValue jsonObj = JSONParser.parse(theJSONDocument);
|
||||
|
@ -168,8 +144,6 @@ public class ReportTemplateToHTML extends Composite {
|
|||
|
||||
reportTable.add(new HTML(toTableHTML));
|
||||
|
||||
//htmlContainer.add(new HTML(toTableHTML));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
GWT.log("error: " + e.getMessage());
|
||||
|
@ -179,13 +153,14 @@ public class ReportTemplateToHTML extends Composite {
|
|||
reportJSON.add(new HTML("<pre>" + ExternalLib.toPrettyPrintJSON(theJSONDocument) + "</pre>"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new report template to HTML. Shows the JSON Document as Table HTML by default
|
||||
* Instantiates a new report template to HTML. Shows the JSON Document as Table
|
||||
* HTML by default
|
||||
*
|
||||
* @param documentLabel the document label
|
||||
* @param documentLabel the document label
|
||||
* @param theJSONDocument the the JSON document
|
||||
* @param openJSONReport the open JSON report
|
||||
* @param openJSONReport the open JSON report
|
||||
*/
|
||||
public ReportTemplateToHTML(String documentLabel, String theJSONDocument, boolean openJSONReport) {
|
||||
|
||||
|
@ -245,16 +220,15 @@ public class ReportTemplateToHTML extends Composite {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void showAsHTMLTable(boolean bool) {
|
||||
showReportAsTable.setVisible(bool);
|
||||
}
|
||||
|
||||
|
||||
public void showAsJSON(boolean bool) {
|
||||
showReportAsJSON.setVisible(bool);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Json to HTML.
|
||||
*
|
||||
|
|
|
@ -451,7 +451,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on loading paginated and filtered list of projects for id: ", e);
|
||||
throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage());
|
||||
throw new Exception("Error occurred on loading list of Projects. Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ h1 {
|
|||
.my-html-table td {
|
||||
padding: 5px;
|
||||
border-bottom: 1px solid gray;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
.my-html-table td:first-child {
|
||||
|
@ -247,6 +248,7 @@ h1 {
|
|||
border: 1px solid #96a5b5;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 5px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.box-table-diplay-project td {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,15 +16,16 @@ import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
|||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
|
||||
import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.FilesetDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
|
||||
|
@ -60,6 +62,38 @@ public class Complex_Tests {
|
|||
public static final String JSON_$_POINTER = "$";
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Complex_Tests.class);
|
||||
|
||||
private LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles;
|
||||
|
||||
public static enum COMMON_IMAGES_FORMAT {
|
||||
gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp
|
||||
}
|
||||
|
||||
public static class ImageDetector {
|
||||
|
||||
private static String[] getNames(Class<? extends Enum<?>> e) {
|
||||
return Arrays.stream(e.getEnumConstants()).map(Enum::name).toArray(String[]::new);
|
||||
}
|
||||
|
||||
public static List<String> listFormatImages;
|
||||
|
||||
static {
|
||||
|
||||
String[] arrayImgs = ImageDetector.getNames(COMMON_IMAGES_FORMAT.class);
|
||||
listFormatImages = Arrays.asList(arrayImgs);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isImage(String mimeType) {
|
||||
if (mimeType == null || mimeType.isEmpty())
|
||||
return false;
|
||||
|
||||
String inputImageFormat = mimeType.replaceAll("image/", "");
|
||||
|
||||
return listFormatImages.contains(inputImageFormat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
|
@ -68,51 +102,73 @@ public class Complex_Tests {
|
|||
clientUCD = GeoportalClientCaller.useCaseDescriptors();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void preloadgCubeProfilesForUCDs() {
|
||||
LOG.debug("preloadgCubeProfilesForUCDs called");
|
||||
try {
|
||||
|
||||
List<UseCaseDescriptor> listUCDs = clientUCD.getList();
|
||||
|
||||
for (UseCaseDescriptor ucd : listUCDs) {
|
||||
|
||||
LOG.debug("Loaded UCD for ID: " + ucd.getId());
|
||||
GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_data_entry;
|
||||
List<HandlerDeclaration> handlers = ucd.getHandlersByType(theHandler.getType());
|
||||
|
||||
if (handlers.size() == 0) {
|
||||
LOG.warn("No handler " + theHandler + "found into UCD " + ucd.getId() + ", continue...");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Loading Handler gcube_profiles
|
||||
HandlerDeclaration dataEntryHandler = handlers.get(0);
|
||||
HandlerDeclarationDV handlerGcubeProfiles = ConvertToDataValueObjectModel
|
||||
.toHandlerDeclarationDV(dataEntryHandler, ucd, GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles);
|
||||
|
||||
LOG.debug("Handler " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " for PROFILE_ID: " + ucd.getId());
|
||||
LOG.debug("" + handlerGcubeProfiles);
|
||||
|
||||
ConfigurationDV<?> config = handlerGcubeProfiles.getConfiguration();
|
||||
// List of gCube Profiles defined in the UCD
|
||||
List<GcubeProfileDV> listGcubeProfiles = toListGcubeProfiles(config);
|
||||
LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
|
||||
|
||||
List<GcubeProfilesMetadataForUCD> listProfilesBean = new ArrayList<GcubeProfilesMetadataForUCD>();
|
||||
// Loading Metadata Profile from IS
|
||||
MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
|
||||
linkedMap_UCDId_gCubeProfiles = new LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>();
|
||||
for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
|
||||
GcubeProfilesMetadataForUCD gCubeProfileMetadataForUCD = new GcubeProfilesMetadataForUCD();
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
List<MetaDataProfileBean> listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(CONTEXT,
|
||||
gcubeProfileDV.getGcubeSecondaryType(), gcubeProfileDV.getGcubeName());
|
||||
|
||||
String key = gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName();
|
||||
LOG.debug("for key: " + key + " readi profiles: " + listGcubeProfiles);
|
||||
gCubeProfileMetadataForUCD.setGcubeProfile(gcubeProfileDV);
|
||||
gCubeProfileMetadataForUCD.setListMetadataProfileBean(listProfiles);
|
||||
listProfilesBean.add(gCubeProfileMetadataForUCD);
|
||||
|
||||
}
|
||||
linkedMap_UCDId_gCubeProfiles.put(ucd.getId(), listProfilesBean);
|
||||
|
||||
for (String key : linkedMap_UCDId_gCubeProfiles.keySet()) {
|
||||
LOG.debug("For key '" + key + "' got profiles: " + linkedMap_UCDId_gCubeProfiles.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadProjectForUCDDataEntry() {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
|
||||
try {
|
||||
LOG.debug("Loading UCD for PROFILE_ID: " + PROFILE_ID);
|
||||
UseCaseDescriptor ucd = clientUCD.getUCDForId(PROFILE_ID);
|
||||
GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_data_entry;
|
||||
List<HandlerDeclaration> handlers = ucd.getHandlersByType(theHandler.getType());
|
||||
|
||||
if (handlers.size() == 0)
|
||||
throw new Exception("No handler " + theHandler + "found");
|
||||
|
||||
// Loading Handler gcube_profiles
|
||||
HandlerDeclaration dataEntryHandler = handlers.get(0);
|
||||
HandlerDeclarationDV handlerGcubeProfiles = ConvertToDataValueObjectModel
|
||||
.toHandlerDeclarationDV(dataEntryHandler, ucd, GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles);
|
||||
|
||||
LOG.debug("Handler " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " for PROFILE_ID: " + PROFILE_ID);
|
||||
LOG.debug("" + handlerGcubeProfiles);
|
||||
|
||||
ConfigurationDV<?> config = handlerGcubeProfiles.getConfiguration();
|
||||
// List of gCube Profiles defined in the UCD
|
||||
List<GcubeProfileDV> listGcubeProfiles = toListGcubeProfiles(config);
|
||||
LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
|
||||
|
||||
// Loading Metadata Profile from IS
|
||||
MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
|
||||
LinkedHashMap<String, List<MetaDataProfileBean>> linkedHashProfiles = new LinkedHashMap<String, List<MetaDataProfileBean>>();
|
||||
for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
List<MetaDataProfileBean> listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(CONTEXT,
|
||||
gcubeProfileDV.getGcubeSecondaryType(), gcubeProfileDV.getGcubeName());
|
||||
|
||||
String key = gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName();
|
||||
LOG.debug("for key: " + key + " readi profiles: " + listGcubeProfiles);
|
||||
linkedHashProfiles.put(gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName(),
|
||||
listProfiles);
|
||||
}
|
||||
|
||||
for (String key : linkedHashProfiles.keySet()) {
|
||||
LOG.debug("For key: " + key + " got profiles: " + linkedHashProfiles.get(key));
|
||||
}
|
||||
|
||||
Project theProject = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
|
@ -126,7 +182,7 @@ public class Complex_Tests {
|
|||
projectView.setTheProjectDV(theProjectDV);
|
||||
|
||||
// NO UCD defined, applyong default
|
||||
if (listGcubeProfiles.size() == 0) {
|
||||
if (linkedMap_UCDId_gCubeProfiles.size() == 0) {
|
||||
LOG.warn("No " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " found in the UCD");
|
||||
LOG.info("Applying default business logic to display the project");
|
||||
SectionView sectionView = new SectionView();
|
||||
|
@ -137,12 +193,15 @@ public class Complex_Tests {
|
|||
projectView.addSectionView(sectionView);
|
||||
}
|
||||
|
||||
List<GcubeProfilesMetadataForUCD> listProfilesBean = linkedMap_UCDId_gCubeProfiles.get(PROFILE_ID);
|
||||
|
||||
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||
|
||||
// Reading the Project according to list of Profile defined in the UCD
|
||||
for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
|
||||
for (GcubeProfilesMetadataForUCD gcubeProfileMetaForUCD : listProfilesBean) {
|
||||
|
||||
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
|
||||
SectionView sectionView = new SectionView();
|
||||
sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
|
||||
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
|
||||
|
@ -197,8 +256,7 @@ public class Complex_Tests {
|
|||
}
|
||||
|
||||
LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
|
||||
List<MetaDataProfileBean> theProfileBeans = linkedHashProfiles
|
||||
.get(gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName());
|
||||
List<MetaDataProfileBean> theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
|
||||
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
|
||||
|
||||
// For each bson.Document creating the SubDocumentView
|
||||
|
@ -230,17 +288,29 @@ public class Complex_Tests {
|
|||
// READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
|
||||
if (filePaths != null) {
|
||||
String fromSectionDocJSON = fromSectionDoc.toJson();
|
||||
List<FilesetDV> listFileSet = new ArrayList<FilesetDV>();
|
||||
List<FilesetDV> listFiles = new ArrayList<FilesetDV>();
|
||||
List<FilesetDV> listImages = new ArrayList<FilesetDV>();
|
||||
for (FilePathDV filePath : filePaths) {
|
||||
|
||||
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
|
||||
List<PayloadDV> listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
|
||||
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
|
||||
FilesetDV filesetDV = new FilesetDV();
|
||||
filesetDV.setName(filePath.getGcubeProfileFieldName());
|
||||
filesetDV.addListPayloadsDV(listPayloads);
|
||||
listFileSet.add(filesetDV);
|
||||
for (Payload payload : listPayloads) {
|
||||
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
|
||||
filesetDV.addPayloadDV(payloadDV);
|
||||
boolean isImage = ImageDetector.isImage(payload.getMimetype());
|
||||
|
||||
if (isImage) {
|
||||
listImages.add(filesetDV);
|
||||
} else {
|
||||
listFiles.add(filesetDV);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
subDocumentView.setListFiles(listFileSet);
|
||||
subDocumentView.setListFiles(listFiles);
|
||||
subDocumentView.setListImages(listImages);
|
||||
}
|
||||
|
||||
sectionView.addSubDocument(subDocumentView);
|
||||
|
@ -254,13 +324,22 @@ public class Complex_Tests {
|
|||
System.out.println("\n\n###### Section Title: " + section.getSectionTitle() + " ######");
|
||||
int i = 1;
|
||||
for (SubDocumentView subDocument : section.getListSubDocuments()) {
|
||||
System.out.println("## "+SubDocumentView.class.getSimpleName()+" n."+i);
|
||||
System.out.println("## " + SubDocumentView.class.getSimpleName() + " n." + i);
|
||||
System.out.println("***** Metadata");
|
||||
System.out.println(prettyPrintJSON(subDocument.getMetadataAsJSON()));
|
||||
System.out.println("***** Files");
|
||||
if (subDocument.getListFiles() != null) {
|
||||
for (FilesetDV filesetDV : subDocument.getListFiles()) {
|
||||
System.out.println("******* Fileset name: " + filesetDV.getName());
|
||||
System.out.println("******* File Fileset name: " + filesetDV.getName());
|
||||
for (PayloadDV payload : filesetDV.getListPayload()) {
|
||||
System.out.println("********* Payload: " + payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("***** Images");
|
||||
if (subDocument.getListImages() != null) {
|
||||
for (FilesetDV filesetDV : subDocument.getListImages()) {
|
||||
System.out.println("******* Image Fileset name: " + filesetDV.getName());
|
||||
for (PayloadDV payload : filesetDV.getListPayload()) {
|
||||
System.out.println("********* Payload: " + payload);
|
||||
}
|
||||
|
@ -278,10 +357,10 @@ public class Complex_Tests {
|
|||
System.out.println("\n\n Procedure termimated!!!");
|
||||
}
|
||||
|
||||
private List<PayloadDV> readPayloadsForFileset(String filesetJSONPath, String sectionJSONDocument) {
|
||||
private List<Payload> readPayloadsForFileset(String filesetJSONPath, String sectionJSONDocument) {
|
||||
LOG.debug("readPayloadsForFileset called");
|
||||
|
||||
List<PayloadDV> listPayloads = new ArrayList<PayloadDV>();
|
||||
List<Payload> listPayloads = new ArrayList<Payload>();
|
||||
String _payloadsJSONPath = String.format("%s.%s", filesetJSONPath, "_payloads");
|
||||
try {
|
||||
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
||||
|
@ -296,7 +375,7 @@ public class Complex_Tests {
|
|||
LOG.trace("The _payloads is a String {}", toStringPayloads);
|
||||
JSONArray jsonArray = new JSONArray(toStringPayloads);
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
PayloadDV payloadDV = Serialization.read(jsonArray.getJSONObject(i).toString(), PayloadDV.class);
|
||||
Payload payloadDV = Serialization.read(jsonArray.getJSONObject(i).toString(), Payload.class);
|
||||
listPayloads.add(payloadDV);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
||||
|
||||
public class GcubeProfilesMetadataForUCD {
|
||||
|
||||
private String profileID;
|
||||
private GcubeProfileDV gcubeProfile;
|
||||
private List<MetaDataProfileBean> listMetadataProfileBean;
|
||||
|
||||
public GcubeProfilesMetadataForUCD() {
|
||||
|
||||
}
|
||||
|
||||
public GcubeProfilesMetadataForUCD(String profileID, GcubeProfileDV gcubeProfile,
|
||||
List<MetaDataProfileBean> listMetadataProfileBean) {
|
||||
|
||||
this.profileID = profileID;
|
||||
this.gcubeProfile = gcubeProfile;
|
||||
this.listMetadataProfileBean = listMetadataProfileBean;
|
||||
}
|
||||
|
||||
public String getProfileID() {
|
||||
return profileID;
|
||||
}
|
||||
|
||||
public GcubeProfileDV getGcubeProfile() {
|
||||
return gcubeProfile;
|
||||
}
|
||||
|
||||
public List<MetaDataProfileBean> getListMetadataProfileBean() {
|
||||
return listMetadataProfileBean;
|
||||
}
|
||||
|
||||
public void setProfileID(String profileID) {
|
||||
this.profileID = profileID;
|
||||
}
|
||||
|
||||
public void setGcubeProfile(GcubeProfileDV gcubeProfile) {
|
||||
this.gcubeProfile = gcubeProfile;
|
||||
}
|
||||
|
||||
public void setListMetadataProfileBean(List<MetaDataProfileBean> listMetadataProfileBean) {
|
||||
this.listMetadataProfileBean = listMetadataProfileBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GcubeProfilesMetadataForUCD [profileID=");
|
||||
builder.append(profileID);
|
||||
builder.append(", gcubeProfile=");
|
||||
builder.append(gcubeProfile);
|
||||
builder.append(", listMetadataProfileBean=");
|
||||
builder.append(listMetadataProfileBean);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue