In progress on "Create Relation facility"

This commit is contained in:
Francesco Mangiacrapa 2022-09-19 18:17:00 +02:00
parent 7932456113
commit f65eb2da95
6 changed files with 220 additions and 99 deletions

View File

@ -1137,7 +1137,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
case CREATE_RELATION: {
mainTabPanel.showCreateRelationPanel(true, resultDocumentDV.getProfileID());
mainTabPanel.showCreateRelationPanel(true, resultDocumentDV);
break;
}

View File

@ -14,6 +14,7 @@ import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole;
import org.gcube.application.geoportalcommon.shared.config.OPERATION_ON_ITEM;
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
@ -145,7 +146,7 @@ public class GeonaMainTabPanel extends Composite {
@UiField
NavLink navDelete;
@UiField
NavLink navCreateRelation;
@ -166,13 +167,13 @@ public class GeonaMainTabPanel extends Composite {
@UiField
PageHeader pageHeaderDataEntry;
@UiField
FlowPanel actionListMainPanel;
@UiField
Hero introGNAHero;
@UiField
FlowPanel createRelationMainPanel;
@ -183,13 +184,15 @@ public class GeonaMainTabPanel extends Composite {
private GeonaRecordsPaginatedView grpw = null;
private List<UseCaseDescriptorDV> ucdProjectTypesForListingDataView = new ArrayList<UseCaseDescriptorDV>();
private ActionListPanel actionListPanel;
private CacheSearchingFilterParametersFromConfig cacheSearchingFilterParameters;
private GcubeUserRole userRole;
private CreateRelationProjectsPanel createRelationProjectsPanel;
/**
* Instantiates a new geona main tab panel.
*
@ -272,8 +275,8 @@ public class GeonaMainTabPanel extends Composite {
alertSortBy.setText(labelASC);
UseCaseDescriptorDV singleUCD = getSelectProjectType();
if (singleUCD != null) {
appManagerBus.fireEvent(new GetListOfRecordsEvent(false,
singleUCD.getProfileID(), getCurrentSearchingFilter(), false));
appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(),
getCurrentSearchingFilter(), false));
}
}
});
@ -291,8 +294,8 @@ public class GeonaMainTabPanel extends Composite {
alertSortBy.setText(labelDESC);
UseCaseDescriptorDV singleUCD = getSelectProjectType();
if (singleUCD != null) {
appManagerBus.fireEvent(new GetListOfRecordsEvent(false,
singleUCD.getProfileID(), getCurrentSearchingFilter(), false));
appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(),
getCurrentSearchingFilter(), false));
}
}
});
@ -338,8 +341,8 @@ public class GeonaMainTabPanel extends Composite {
UseCaseDescriptorDV singleUCD = getSelectProjectType();
if (singleUCD != null) {
appManagerBus.fireEvent(new GetListOfRecordsEvent(false,
singleUCD.getProfileID(), getCurrentSearchingFilter(), true));
appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(),
getCurrentSearchingFilter(), true));
}
}
@ -363,7 +366,8 @@ public class GeonaMainTabPanel extends Composite {
listDocuments = grpw.getSelectItems();
}
appManagerBus.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.VIEW_ON_MAP));
appManagerBus
.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.VIEW_ON_MAP));
}
});
@ -377,7 +381,8 @@ public class GeonaMainTabPanel extends Composite {
listDocuments = grpw.getSelectItems();
}
appManagerBus.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.VIEW_REPORT));
appManagerBus
.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.VIEW_REPORT));
}
});
@ -392,7 +397,8 @@ public class GeonaMainTabPanel extends Composite {
listDocuments = grpw.getSelectItems();
}
appManagerBus.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.EDIT_PROJECT));
appManagerBus
.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.EDIT_PROJECT));
}
});
@ -405,11 +411,11 @@ public class GeonaMainTabPanel extends Composite {
listDocuments = grpw.getSelectItems();
}
appManagerBus
.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.DELETE_PROJECT));
appManagerBus.fireEvent(
new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.DELETE_PROJECT));
}
});
navCreateRelation.addClickHandler(new ClickHandler() {
@Override
@ -418,15 +424,14 @@ public class GeonaMainTabPanel extends Composite {
if (grpw != null && grpw.getSelectItems() != null) {
listDocuments = grpw.getSelectItems();
}
OperationOnItemEvent oIE = new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.CREATE_RELATION);
OperationOnItemEvent oIE = new OperationOnItemEvent<DocumentDV>(listDocuments,
OPERATION_ON_ITEM.CREATE_RELATION);
oIE.setSourceElement(navCreateRelation.getElement());
appManagerBus
.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.CREATE_RELATION));
appManagerBus.fireEvent(
new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.CREATE_RELATION));
}
});
searchField.addKeyPressHandler(new KeyPressHandler() {
@ -449,8 +454,8 @@ public class GeonaMainTabPanel extends Composite {
UseCaseDescriptorDV singleUCD = getSelectProjectType();
if (singleUCD != null) {
appManagerBus.fireEvent(new GetListOfRecordsEvent(false,
singleUCD.getProfileID(), getCurrentSearchingFilter(), false));
appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(),
getCurrentSearchingFilter(), false));
}
resetSearch.setVisible(false);
@ -468,15 +473,14 @@ public class GeonaMainTabPanel extends Composite {
/**
* Sets the role label.
*
* @param userRole the user role
* @param userRole the user role
* @param roleTitle the role title
*/
public void setRole(GcubeUserRole userRole) {
this.userRole = userRole;
String msg = "Logged in as ";
if (userRole != null && userRole.getName() != null) {
msg += userRole.getName().substring(userRole.getName().indexOf("-") + 1,
userRole.getName().length());
msg += userRole.getName().substring(userRole.getName().indexOf("-") + 1, userRole.getName().length());
} else
msg += "Member";
roleLabel.setText(msg);
@ -496,8 +500,8 @@ public class GeonaMainTabPanel extends Composite {
UseCaseDescriptorDV singleUCD = getSelectProjectType();
if (singleUCD != null) {
appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(),
getCurrentSearchingFilter(), false));
appManagerBus.fireEvent(
new GetListOfRecordsEvent(false, singleUCD.getProfileID(), getCurrentSearchingFilter(), false));
}
}
@ -653,8 +657,8 @@ public class GeonaMainTabPanel extends Composite {
alertProjectType.setText(singleUCD.getName());
// setFilteringParameters(displayFields, sortByFields, searchForFields,
// currentSearchingFilter);
appManagerBus.fireEvent(new GetListOfRecordsEvent(true, singleUCD.getProfileID(),
getCurrentSearchingFilter(), true));
appManagerBus.fireEvent(
new GetListOfRecordsEvent(true, singleUCD.getProfileID(), getCurrentSearchingFilter(), true));
}
}
@ -722,7 +726,7 @@ public class GeonaMainTabPanel extends Composite {
ddProjectType.add(link);
}
initActionListPanel(ucd);
}
@ -751,10 +755,10 @@ public class GeonaMainTabPanel extends Composite {
}
}
public void initActionListPanel(UseCaseDescriptorDV ucd) {
GWT.log("Init ActionListPanel for UCD: "+ucd);
GWT.log("Init ActionListPanel for UCD: " + ucd);
// Setting Project type having HANDLER WORKFLOW ACTION
HandlerDeclarationDV dataListHandler = UCD_Util.getHandlerDeclarationFor(ucd,
GEOPORTAL_DATA_HANDLER.geoportal_workflow_action_list);
@ -767,15 +771,20 @@ public class GeonaMainTabPanel extends Composite {
actionListPanel = new ActionListPanel(appManagerBus, ucd.getName(), ucd.getProfileID(), listActionDef);
actionListMainPanel.add(actionListPanel);
}else {
} else {
actionListMainPanel.clear();
actionListMainPanel.setVisible(false);
}
}
public <T> void showActionsOnSelected(List<T> selectItems) {
actionListPanel.showActionsOnSelected(selectItems, userRole);
if (createRelationProjectsPanel != null && createRelationProjectsPanel.isVisible()) {
createRelationProjectsPanel.selectedProject((ResultDocumentDV) selectItems.get(0));
}
}
/**
@ -844,18 +853,16 @@ public class GeonaMainTabPanel extends Composite {
this.pageHeaderDataEntry.setSubtext("New: " + hDV.getItemType());
}
public void showCreateRelationPanel(boolean bool, String profileID){
public void showCreateRelationPanel(boolean bool, ResultDocumentDV resultDocumentDV) {
createRelationMainPanel.clear();
createRelationMainPanel.setVisible(bool);
//if hiding, returns
if(!bool) {
// if hiding, returns
if (!bool) {
return;
}
CreateRelationProjectsPanel createPanel = new CreateRelationProjectsPanel(profileID, appManagerBus);
createRelationMainPanel.add(createPanel);
createRelationProjectsPanel = new CreateRelationProjectsPanel(appManagerBus, resultDocumentDV);
createRelationMainPanel.add(createRelationProjectsPanel);
}
}

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.relation;
import java.util.HashMap;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
@ -23,6 +24,7 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
@ -65,25 +67,30 @@ public class CreateRelationProjectsPanel extends Composite {
@UiField
ListBox listBoxRelationNames;
@UiField
Button closeButton;
@UiField
Button buttCreateRelation;
@UiField
Alert alertMessage;
private ResultDocumentDV[] selectedProject = new ResultDocumentDV[2];
private HashMap<Integer, ResultDocumentDV> selectedProjects = new HashMap<Integer, ResultDocumentDV>(2);
private HandlerManager appManagerBus;
public CreateRelationProjectsPanel(String profileID, HandlerManager appManagerBus) {
public CreateRelationProjectsPanel(HandlerManager appManagerBus, ResultDocumentDV project) {
initWidget(uiBinder.createAndBindUi(this));
this.profileID = profileID;
this.appManagerBus = appManagerBus;
closeButton.setType(ButtonType.LINK);
closeButton.setIcon(IconType.REMOVE);
closeButton.setIconSize(IconSize.LARGE);
closeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
appManagerBus.fireEvent(new CloseCreateRelationGUIEvent());
@ -98,7 +105,6 @@ public class CreateRelationProjectsPanel extends Composite {
@Override
public void onSuccess(List<String> relationshipNames) {
for (String relName : relationshipNames) {
// NavLink navLink = new NavLink(relName);
listBoxRelationNames.addItem(relName, relName);
}
@ -122,7 +128,8 @@ public class CreateRelationProjectsPanel extends Composite {
@Override
public void onClick(ClickEvent event) {
selectedProject[0] = null;
selectedProjects.put(0, null);
firstItemAlert.setVisible(true);
firstProjectPanelContainer.clear();
}
@ -131,18 +138,92 @@ public class CreateRelationProjectsPanel extends Composite {
buttSecondProjectReset.setType(ButtonType.LINK);
buttSecondProjectReset.setIcon(IconType.REMOVE_SIGN);
buttSecondProjectReset.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
selectedProjects.put(1, null);
secondItemAlert.setVisible(true);
secondProjectPanelContainer.clear();
}
});
buttCreateRelation.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
checkFormPassed();
}
});
selectedProject(project);
}
public boolean checkFormPassed() {
alertMessage.setVisible(false);
ResultDocumentDV first = selectedProjects.get(0);
if (first == null) {
alertMessage.setVisible(true);
alertMessage.setText("You must select the first project from the 'List of Project' Table");
return false;
}
ResultDocumentDV second = selectedProjects.get(1);
if (second == null) {
alertMessage.setVisible(true);
alertMessage.setText("You must select the second project from the 'List of Project' Table");
return false;
}
if(first.getId().compareTo(second.getId())==0) {
alertMessage.setVisible(true);
alertMessage.setText("First and Second project cannot be the same project");
return false;
}
return true;
}
public void selectedProject(ResultDocumentDV project) {
if (selectedProject.length == 0) {
selectedProject[0] = project;
firstProjectPanelContainer
.add(new ReportTemplateToHTML("First Project", project.getDocumentAsJSON(), true, false));
} else if (selectedProject.length == 1) {
selectedProject[1] = project;
secondProjectPanelContainer
.add(new ReportTemplateToHTML("Second Project", project.getDocumentAsJSON(), true, false));
ResultDocumentDV first = selectedProjects.get(0);
// String htmlMsg = "Selected";
// htmlMsg += "<ul>";
// htmlMsg += "<li>id: " + project.getId() + "</li>";
// htmlMsg += "<li>"+project.getFirstEntryOfMap().getKey()+": " + project.getFirstEntryOfMap().getValue() + "</li>";
// htmlMsg += "</ul>";
String htmlMsg = "Selected: <b>"+project.getFirstEntryOfMap().getValue()+"</b> (id: "+project.getId()+")";
if (first == null) {
firstItemAlert.setVisible(false);
selectedProjects.put(0, project);
firstProjectPanelContainer.add(new HTML(htmlMsg));
ReportTemplateToHTML rtth = new ReportTemplateToHTML("", project.getDocumentAsJSON(), false, false);
rtth.showAsJSON(false);
firstProjectPanelContainer.add(rtth);
return;
}
ResultDocumentDV second = selectedProjects.get(1);
if (second == null) {
secondItemAlert.setVisible(false);
selectedProjects.put(1, project);
secondProjectPanelContainer.add(new HTML(htmlMsg));
ReportTemplateToHTML rtth = new ReportTemplateToHTML("", project.getDocumentAsJSON(), false, false);
rtth.showAsJSON(false);
secondProjectPanelContainer.add(rtth);
}
}

View File

@ -15,6 +15,8 @@
border-bottom: 1px solid #cdcdcd;
padding-top: 5px;
padding-bottom: 5px;
text-align: center;
margin-top: 10px;
}
.margin-top-10 {
@ -27,42 +29,51 @@
.to-align-right {
position: absolute;
top: 10px;
right: 10px;
right: 5px;
}
.relation-panel {
max-height: 450px;
}
</ui:style>
<g:HTMLPanel>
<b:Button ui:field="closeButton"
addStyleNames="{style.to-align-right}"></b:Button>
<g:HTMLPanel ui:field="panelTitle"
addStyleNames="{style.creation-rel-title}">Create Relation</g:HTMLPanel>
<b:Alert ui:field="alertMessage" visible="false"></b:Alert>
<g:HTMLPanel ui:field="firstPanelContainer"
addStyleNames="{style.margin-top-10}">
<g:FlowPanel>
<b:Label>First Project</b:Label>
<b:Button ui:field="buttFirtProjectReset">Reset</b:Button>
</g:FlowPanel>
<b:Alert ui:field="firstItemAlert">Select project from the "List of Projects"
Table</b:Alert>
<g:FlowPanel ui:field="firstProjectPanelContainer"></g:FlowPanel>
<g:ScrollPanel addStyleNames="scroll-panel-relation">
<g:HTMLPanel addStyleNames="{style.relation-panel}">
<b:Button ui:field="closeButton"
addStyleNames="{style.to-align-right}"></b:Button>
<g:HTMLPanel ui:field="panelTitle"
addStyleNames="{style.creation-rel-title}">Create Relationship</g:HTMLPanel>
<g:HTMLPanel ui:field="firstPanelContainer"
addStyleNames="{style.margin-top-10}">
<g:FlowPanel>
<b:Label>First Project</b:Label>
<b:Button ui:field="buttFirtProjectReset">Reset</b:Button>
</g:FlowPanel>
<b:Alert ui:field="firstItemAlert">Select project from the "List of
Projects"
Table</b:Alert>
<g:FlowPanel ui:field="firstProjectPanelContainer"></g:FlowPanel>
</g:HTMLPanel>
<g:HTMLPanel addStyleNames="{style.list-box-delimiter}">
<b:ListBox ui:field="listBoxRelationNames">
</b:ListBox>
</g:HTMLPanel>
<g:HTMLPanel ui:field="secondPanelContainer"
addStyleNames="{style.margin-top-10}">
<g:FlowPanel>
<b:Label>Second Project</b:Label>
<b:Button ui:field="buttSecondProjectReset">Reset</b:Button>
</g:FlowPanel>
<b:Alert ui:field="secondItemAlert">Select project from the "List of Projects"
Table</b:Alert>
<g:FlowPanel ui:field="secondProjectPanelContainer"></g:FlowPanel>
</g:HTMLPanel>
<b:Button type="PRIMARY" ui:field="buttCreateRelation"
addStyleNames="{style.butt-create}">Create</b:Button>
</g:HTMLPanel>
<g:HTMLPanel addStyleNames="{style.list-box-delimiter}">
<b:ListBox ui:field="listBoxRelationNames">
</b:ListBox>
</g:HTMLPanel>
<g:HTMLPanel ui:field="secondPanelContainer"
addStyleNames="{style.margin-top-10}">
<g:FlowPanel>
<b:Label>Second Project</b:Label>
<b:Button ui:field="buttSecondProjectReset">Reset</b:Button>
</g:FlowPanel>
<b:Alert ui:field="secondItemAlert">Select project from the "List of
Projects"
Table</b:Alert>
<g:FlowPanel ui:field="secondProjectPanelContainer"></g:FlowPanel>
</g:HTMLPanel>
<b:Alert type="ERROR" ui:field="alertMessage" visible="false"></b:Alert>
<b:Button type="PRIMARY" ui:field="buttCreateRelation"
addStyleNames="{style.butt-create}">Create</b:Button>
</g:HTMLPanel>
</g:ScrollPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -179,7 +179,7 @@ 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
*
@ -245,6 +245,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.
@ -252,7 +261,7 @@ public class ReportTemplateToHTML extends Composite {
* @param jsonTxt the json txt
* @return the string
*/
public static native String jsonToHTML(String jsonTxt)/*-{
private static native String jsonToHTML(String jsonTxt)/*-{
try {
var jsonObj = JSON.parse(jsonTxt);

View File

@ -208,3 +208,16 @@ h1 {
z-index: 10000;
border: 1px solid gray;
}
#geoportal-loaders {
text-align: center;
width: 100%;
}
.scroll-panel-relation {
max-height: 500px;
}
.scroll-panel-relation .accordion-group {
border: 0 !important;
}