several improvements

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/grsf-manage-widget@162878 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2018-02-03 18:17:37 +00:00
parent 6612e05a54
commit 55a97c4802
22 changed files with 477 additions and 663 deletions

View File

@ -12,7 +12,7 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> <classpathentry kind="src" output="target/test-classes" path="src/test/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -23,14 +23,14 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="${webappDirectory}/WEB-INF/classes" path="src/main/resources"> <classpathentry kind="src" output="${webappDirectory}/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="owner.project.facets" value="java"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="${webappDirectory}/WEB-INF/classes"/> <classpathentry kind="output" path="${webappDirectory}/WEB-INF/classes"/>

View File

@ -1,3 +1,4 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
lastWarOutDir=/Users/costantinoperciante/Documents/workspace/grsf-manage-widget/target
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -4,6 +4,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
<dependent-module archiveName="ckan-util-library-2.4.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="grsf-manage-widget"/> <property name="context-root" value="grsf-manage-widget"/>
<property name="java-output-path" value="/grsf-manage-widget/target/grsf-manage-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/grsf-manage-widget/target/grsf-manage-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</wb-module> </wb-module>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<faceted-project> <faceted-project>
<fixed facet="wst.jsdt.web"/> <fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="2.3"/> <installed facet="jst.web" version="2.3"/>
<installed facet="wst.jsdt.web" version="1.0"/> <installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.8"/>
</faceted-project> </faceted-project>

View File

@ -243,5 +243,4 @@
</plugins> </plugins>
</build> </build>
<packaging>war</packaging>
</project> </project>

View File

@ -1,7 +1,5 @@
package org.gcube.datacatalogue.grsf_manage_widget.client; package org.gcube.datacatalogue.grsf_manage_widget.client;
import java.util.List;
import org.gcube.datacatalogue.grsf_manage_widget.shared.ManageProductBean; import org.gcube.datacatalogue.grsf_manage_widget.shared.ManageProductBean;
import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteService;
@ -27,23 +25,7 @@ public interface GRSFManageWidgetService extends RemoteService {
/** /**
* Notify product update * Notify product update
*/ */
String notifyProductUpdate(ManageProductBean bean, List<String> hashtags) throws Exception; String notifyProductUpdate(ManageProductBean bean) throws Exception;
// /**
// * Check that a record with such semantic identifier exists
// * @param semanticIdentifier
// * @return true or false
// */
// boolean checkSemanticIdentifierExists(String semanticIdentifier) throws Exception;
//
// /**
// * Check that a record with such semantic identifier exists in a given domain
// * @param semanticIdentifier
// * @param domain
// * @return
// * @throws Exception
// */
// boolean checkSemanticIdentifierExistsInDomain(String semanticIdentifier, String domain) throws Exception;
/** /**
* Identifier of the record (UUID) * Identifier of the record (UUID)

View File

@ -3,8 +3,6 @@
*/ */
package org.gcube.datacatalogue.grsf_manage_widget.client; package org.gcube.datacatalogue.grsf_manage_widget.client;
import java.util.List;
import org.gcube.datacatalogue.grsf_manage_widget.shared.ManageProductBean; import org.gcube.datacatalogue.grsf_manage_widget.shared.ManageProductBean;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
@ -15,7 +13,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
*/ */
public interface GRSFManageWidgetServiceAsync { public interface GRSFManageWidgetServiceAsync {
void notifyProductUpdate(ManageProductBean bean, List<String> hashtags, void notifyProductUpdate(ManageProductBean bean,
AsyncCallback<String> callback); AsyncCallback<String> callback);
void getProductBeanById(String identifier, void getProductBeanById(String identifier,
@ -23,12 +21,6 @@ public interface GRSFManageWidgetServiceAsync {
void isAdminUser(AsyncCallback<Boolean> callback); void isAdminUser(AsyncCallback<Boolean> callback);
// void checkSemanticIdentifierExists(String semanticIdentifier,
// AsyncCallback<Boolean> callback);
//
// void checkSemanticIdentifierExistsInDomain(String semanticIdentifier,
// String domain, AsyncCallback<Boolean> callback);
void checkIdentifierExists(String id, void checkIdentifierExists(String id,
AsyncCallback<String> callback); AsyncCallback<String> callback);

View File

@ -2,17 +2,13 @@ package org.gcube.datacatalogue.grsf_manage_widget.client.view;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.gcube.datacatalogue.common.enums.Status; import org.gcube.datacatalogue.common.enums.Status;
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetService; import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetService;
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetServiceAsync; import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetServiceAsync;
import org.gcube.datacatalogue.grsf_manage_widget.client.events.HideManagementPanelEvent; import org.gcube.datacatalogue.grsf_manage_widget.client.events.HideManagementPanelEvent;
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.ConnectToWidget; import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.ConnectToWidget;
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.FormEntryModel;
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SimilarGRSFRecordWidget; import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SimilarGRSFRecordWidget;
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SourceWidget; import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SourceWidget;
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SuggestMerges; import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SuggestMerges;
@ -33,7 +29,6 @@ import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.TextArea; import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.TextBox; import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.SelectElement; import com.google.gwt.dom.client.SelectElement;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
@ -91,6 +86,9 @@ public class ManageProductWidget extends Composite{
@UiField @UiField
VerticalPanel panelForSourceItems; VerticalPanel panelForSourceItems;
@UiField
ControlGroup similarGRSFRecordGroup;
@UiField @UiField
VerticalPanel panelForSimilarGRSFRecords; VerticalPanel panelForSimilarGRSFRecords;
@ -140,9 +138,8 @@ public class ManageProductWidget extends Composite{
private final static String STATUS_UPDATE_ERROR = "Sorry, there was a problem while trying to update the status of this record"; private final static String STATUS_UPDATE_ERROR = "Sorry, there was a problem while trying to update the status of this record";
protected static final String ERROR_ON_RETRIEVING_BEAN = "It seems there was a problem while contacting the service..."; protected static final String ERROR_ON_RETRIEVING_BEAN = "It seems there was a problem while contacting the service...";
protected static final String NO_GRSF_RECORD_BEAN = "This record is not a GRSF record, thus it cannot be managed"; protected static final String NO_GRSF_RECORD_BEAN = "This record is not a GRSF record, thus it cannot be managed";
protected static final String NO_ADMIN_ROLE = "Sorry but it seems you do not have the rights to manage records." protected static final String NO_ADMIN_ROLE = "Sorry but it seems you do not have the rights to manage records."
+ " You are suggested to contact the VRE Manager if something is wrong with this"; + " You are suggested to contact the VRE Manager if something is wrong with this.";
// event bus shared with the portlet // event bus shared with the portlet
private HandlerManager eventBus = null; private HandlerManager eventBus = null;
@ -217,7 +214,6 @@ public class ManageProductWidget extends Composite{
@Override @Override
public void onSuccess(ManageProductBean resBean) { public void onSuccess(ManageProductBean resBean) {
if(resBean == null){ if(resBean == null){
showInfo(ERROR_ON_RETRIEVING_BEAN, AlertType.ERROR); showInfo(ERROR_ON_RETRIEVING_BEAN, AlertType.ERROR);
formUpdate.setVisible(false); formUpdate.setVisible(false);
@ -241,9 +237,12 @@ public class ManageProductWidget extends Composite{
panelForSourceItems.add(new SourceWidget(availableSources)); panelForSourceItems.add(new SourceWidget(availableSources));
// manage similar GRSF records, if any // manage similar GRSF records, if any
List<SimilarGRSFRecord> availableGRSFSimilarRecords = bean.getSimilarGrsfRecords(); if(bean.getSimilarGrsfRecords() != null && !bean.getSimilarGrsfRecords().isEmpty()){
similarRecordPanel = new SimilarGRSFRecordWidget(availableGRSFSimilarRecords/*, service*/); List<SimilarGRSFRecord> availableGRSFSimilarRecords = bean.getSimilarGrsfRecords();
panelForSimilarGRSFRecords.add(similarRecordPanel); similarRecordPanel = new SimilarGRSFRecordWidget(availableGRSFSimilarRecords);
panelForSimilarGRSFRecords.add(similarRecordPanel);
}else
similarGRSFRecordGroup.setVisible(false);
// further suggested merges // further suggested merges
suggestedMergesPanel = new SuggestMerges(service); suggestedMergesPanel = new SuggestMerges(service);
@ -253,19 +252,16 @@ public class ManageProductWidget extends Composite{
connectWidget = new ConnectToWidget(bean, service); connectWidget = new ConnectToWidget(bean, service);
panelForConnectOtherRecords.add(connectWidget); panelForConnectOtherRecords.add(connectWidget);
// check if we need to show more
if(bean.getExtrasIfAvailable() != null && !bean.getExtrasIfAvailable().isEmpty())
addExtrasAfter(bean, productGrsfTypeGroup);
// check for new status box // check for new status box
List<Status> statusToShow = new ArrayList<Status>(STATUS); List<Status> statusToShow = new ArrayList<Status>(STATUS);
statusToShow.remove(bean.getCurrentStatus()); statusToShow.remove(bean.getCurrentStatus());
statusToShow.remove(Status.To_be_Merged); // it cannot be set by a user
// if the record isn't approved, then remove also archived // if the record isn't approved, then remove also archived
if(!bean.getCurrentStatus().equals(Status.Approved)) if(!bean.getCurrentStatus().equals(Status.Approved))
statusToShow.remove(Status.Archived); statusToShow.remove(Status.Archived);
listBoxStatus.addItem("Select the new status"); listBoxStatus.addItem("Select a new status");
listBoxStatus.getElement().<SelectElement>cast().getOptions().getItem(0).setDisabled(true); listBoxStatus.getElement().<SelectElement>cast().getOptions().getItem(0).setDisabled(true);
for (Status availableStatus : statusToShow) { for (Status availableStatus : statusToShow) {
listBoxStatus.addItem(availableStatus.toString()); listBoxStatus.addItem(availableStatus.toString());
@ -311,39 +307,15 @@ public class ManageProductWidget extends Composite{
} }
/**
* Add extras if available after controlGroupBefore
* @param bean
* @param productTypeGroup
*/
private void addExtrasAfter(ManageProductBean bean,
ControlGroup controlGroupBefore) {
int index = formUpdate.getWidgetIndex(controlGroupBefore);
Map<String, String> extras = bean.getExtrasIfAvailable();
Iterator<Entry<String, String>> iterator = extras.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<java.lang.String, java.lang.String> entry = (Map.Entry<java.lang.String, java.lang.String>) iterator
.next();
formUpdate.insert(new FormEntryModel(entry.getKey(), entry.getValue()), index);
index++;
}
}
@UiHandler("confirmButton") @UiHandler("confirmButton")
void onSaveButton(ClickEvent ce){ void onSaveButton(ClickEvent ce){
listBoxStatusGroup.setType(ControlGroupType.NONE); // if the status has not be changed ...
if(listBoxStatus.getSelectedIndex() <= 0)
if(listBoxStatus.getSelectedIndex() <= 0){ bean.setNewStatus(bean.getCurrentStatus());
listBoxStatusGroup.setType(ControlGroupType.ERROR); else
return; bean.setNewStatus(Status.fromString(listBoxStatus.getSelectedItemText()));
}
manageProductModal.setCloseVisible(false); manageProductModal.setCloseVisible(false);
cancelButton.setEnabled(false); cancelButton.setEnabled(false);
confirmButton.setEnabled(false); confirmButton.setEnabled(false);
@ -354,19 +326,20 @@ public class ManageProductWidget extends Composite{
// evaluate the connections and the actions on them // evaluate the connections and the actions on them
bean.setConnections(connectWidget.getConnectList()); bean.setConnections(connectWidget.getConnectList());
// update similar records and to connect // update similar records and to connect
bean.setSimilarGrsfRecords(similarRecordPanel.getSimilarRecords()); if(similarRecordPanel != null)
bean.setSimilarGrsfRecords(similarRecordPanel.getSimilarRecords());
bean.getSimilarGrsfRecords().addAll(suggestedMergesPanel.getSimilarRecords()); bean.getSimilarGrsfRecords().addAll(suggestedMergesPanel.getSimilarRecords());
// set new values // set new values
bean.setAnnotation(new HTML(annotationArea.getText().trim()).getText()); bean.setAnnotation(new HTML(annotationArea.getText().trim()).getText());
bean.setNewStatus(Status.fromString(listBoxStatus.getSelectedItemText()));
// traceability flag // traceability flag
bean.setTraceabilityFlag(traceabilityFlag.getValue()); bean.setTraceabilityFlag(traceabilityFlag.getValue());
service.notifyProductUpdate(bean, null, new AsyncCallback<String>() { // TODO add hashtags here service.notifyProductUpdate(bean, new AsyncCallback<String>() {
@Override @Override
public void onSuccess(String result) { public void onSuccess(String result) {

View File

@ -8,7 +8,7 @@
} }
</ui:style> </ui:style>
<g:HTMLPanel> <g:HTMLPanel>
<b:Modal ui:field="manageProductModal" title="Manage item" <b:Modal ui:field="manageProductModal" title="Manage GRSF Record"
backdrop="STATIC" keyboard="true" animation="true" closeVisible="true"> backdrop="STATIC" keyboard="true" animation="true" closeVisible="true">
<g:VerticalPanel width="100%" ui:field="container"> <g:VerticalPanel width="100%" ui:field="container">
@ -83,7 +83,7 @@
<b:ControlGroup ui:field="sourcesGroup"> <b:ControlGroup ui:field="sourcesGroup">
<b:ControlLabel title="Sources"> <b:ControlLabel title="Sources">
<b>Source(s):</b> <b>Source Record(s):</b>
</b:ControlLabel> </b:ControlLabel>
<b:Controls> <b:Controls>
<g:VerticalPanel ui:field="panelForSourceItems" <g:VerticalPanel ui:field="panelForSourceItems"

View File

@ -14,6 +14,7 @@ import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.Icon; import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.TextBox; import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Float; import com.google.gwt.dom.client.Style.Float;
@ -57,8 +58,9 @@ public class ConnectToWidget extends Composite{
Button suggestRecord; Button suggestRecord;
private List<Tuple> connectList = new ArrayList<Tuple>(0); private List<Tuple> connectList = new ArrayList<Tuple>(0);
private List<ConnectedBean> currentlyConnected = null; private List<ConnectedBean> currentlyConnected; // they can be "unconnected" or "removed"
private List<ConnectedBean> suggestedByKnowledgeBase; private List<ConnectedBean> suggestedByKnowledgeBase; // they can be "connected"
private List<ConnectedBean> suggestedByUser = new ArrayList<ConnectedBean>(0); // they are "connected" if valid
private GRSFManageWidgetServiceAsync service; private GRSFManageWidgetServiceAsync service;
public ConnectToWidget(final ManageProductBean bean, GRSFManageWidgetServiceAsync service) { public ConnectToWidget(final ManageProductBean bean, GRSFManageWidgetServiceAsync service) {
@ -66,18 +68,6 @@ public class ConnectToWidget extends Composite{
this.service = service; this.service = service;
// add the one suggested by the knowledge base
suggestedByKnowledgeBase = bean.getSuggestedByKnowledgeBase();
if(suggestedByKnowledgeBase != null){
connectPanel.add(new HTML("<hr style=\"width:100%;\"/>"));
for (ConnectedBean connected : suggestedByKnowledgeBase) {
Widget widget = buildWidgetForConnected(connected, true);
connectPanel.add(widget);
connectPanel.add(new HTML("<hr style=\"width:100%;\"/>"));
}
}
// get already connected beans, and suggested ones // get already connected beans, and suggested ones
currentlyConnected = bean.getCurrentConnections(); currentlyConnected = bean.getCurrentConnections();
@ -90,25 +80,39 @@ public class ConnectToWidget extends Composite{
} }
} }
// manage the button for manual suggestion // add the one suggested by the knowledge base, they can be just "connected"
String acceptedDomain = bean.getGrsfDomain().equalsIgnoreCase(Product_Type.STOCK.getOrigName()) ? Product_Type.FISHERY.getOrigName() : Product_Type.STOCK.getOrigName(); // inverted suggestedByKnowledgeBase = bean.getSuggestedByKnowledgeBaseConnections();
suggestRecord.setTitle("Connect this " + bean.getGrsfDomain() + " record to a " + acceptedDomain + " record ");
suggestRecord.setIcon(IconType.PLUS_SIGN);
suggestRecord.getElement().getStyle().setFloat(Float.RIGHT);
// add handler
suggestRecord.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
ConnectedBean cb = new ConnectedBean();
Tuple t = buildWidgetConnect(cb);
connectList.add(t);
connectPanel.add(t.getW());
if(suggestedByKnowledgeBase != null){
for (ConnectedBean connected : suggestedByKnowledgeBase) {
Widget widget = buildWidgetForConnected(connected, true);
connectPanel.add(widget);
connectPanel.add(new HTML("<hr style=\"width:100%;\"/>"));
} }
}); }
// manage the button for manual suggestion
final String acceptedDomain = bean.getGrsfDomain().equalsIgnoreCase(Product_Type.STOCK.getOrigName()) ?
Product_Type.FISHERY.getOrigName() : Product_Type.STOCK.getOrigName();
suggestRecord.setTitle("Connect this " + bean.getGrsfDomain() + " record to a " + acceptedDomain + " record ");
suggestRecord.setText("Add Connection");
suggestRecord.setType(ButtonType.LINK);
suggestRecord.getElement().getStyle().setFontWeight(FontWeight.BOLD);
suggestRecord.getElement().getStyle().setFloat(Float.RIGHT);
// add handler
suggestRecord.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
ConnectedBean cb = new ConnectedBean();
Tuple t = buildWidgetConnect(cb, acceptedDomain);
connectList.add(t);
connectPanel.add(t.getW());
}
});
} }
@ -123,19 +127,19 @@ public class ConnectToWidget extends Composite{
VerticalPanel leftPanel = new VerticalPanel(); VerticalPanel leftPanel = new VerticalPanel();
leftPanel.setWidth("80%"); leftPanel.setWidth("80%");
leftPanel.getElement().getStyle().setMarginLeft(20, Unit.PX); leftPanel.getElement().getStyle().setMarginLeft(20, Unit.PX);
Paragraph name = new Paragraph("Record name: " + (connected.getDestName() != null? connected.getDestName() : "Unavailable")); Paragraph name = new Paragraph("Record Name: " + (connected.getTitle() != null? connected.getTitle() : "Unavailable"));
leftPanel.add(name); leftPanel.add(name);
Paragraph semanticIdentifier = new Paragraph("Semantic Identifier: " + Paragraph semanticIdentifier = new Paragraph("Semantic Identifier: " +
connected.getDestSemanticIdentifier()); connected.getSemanticIdentifier());
leftPanel.add(semanticIdentifier); leftPanel.add(semanticIdentifier);
Paragraph identifier = new Paragraph("Record UUID: " + Paragraph identifier = new Paragraph("Record UUID: " +
connected.getDestKnowledgeBaseId()); connected.getKnowledgeBaseId());
leftPanel.add(identifier); leftPanel.add(identifier);
Anchor view = new Anchor(); Anchor view = new Anchor();
view.setHref(connected.getDestUrl()); view.setHref(connected.getUrl());
view.setText("View"); view.setText("View");
view.setTitle("Click to view the similar record"); view.setTitle("Click to view the similar record");
view.setTarget("_blank"); view.setTarget("_blank");
@ -145,10 +149,10 @@ public class ConnectToWidget extends Composite{
VerticalPanel rightPanel = new VerticalPanel(); VerticalPanel rightPanel = new VerticalPanel();
rightPanel.setWidth("20%"); rightPanel.setWidth("20%");
rightPanel.getElement().getStyle().setFloat(Float.RIGHT); rightPanel.getElement().getStyle().setFloat(Float.RIGHT);
if(!suggestedByKb){ if(!suggestedByKb){
final CheckBox removeExtra = new CheckBox("Remove"); final CheckBox removeExtra = new CheckBox("Remove");
removeExtra.setTitle("Remove this connections"); removeExtra.setTitle("Remove this connection");
removeExtra.addClickHandler(new ClickHandler() { removeExtra.addClickHandler(new ClickHandler() {
@Override @Override
@ -158,9 +162,9 @@ public class ConnectToWidget extends Composite{
}); });
rightPanel.add(removeExtra); rightPanel.add(removeExtra);
} }
final CheckBox connect = new CheckBox("Connect"); final CheckBox connect = new CheckBox("Connect");
connect.setValue(suggestedByKb); // automatically check the value connect.setValue(!suggestedByKb); // automatically check/uncheck the value it based on the suggestion
connect.setTitle("Connect this record"); connect.setTitle("Connect this record");
connect.addClickHandler(new ClickHandler() { connect.addClickHandler(new ClickHandler() {
@ -170,7 +174,6 @@ public class ConnectToWidget extends Composite{
} }
}); });
rightPanel.add(connect); rightPanel.add(connect);
hp.add(leftPanel); hp.add(leftPanel);
hp.add(rightPanel); hp.add(rightPanel);
hp.getElement().getStyle().setPadding(10, Unit.PX); hp.getElement().getStyle().setPadding(10, Unit.PX);
@ -182,8 +185,9 @@ public class ConnectToWidget extends Composite{
* Builds up a widget for connecting records. * Builds up a widget for connecting records.
* @param w the widget * @param w the widget
* @param cb the connectBean. * @param cb the connectBean.
* @param acceptedDomain
*/ */
private Tuple buildWidgetConnect(final ConnectedBean cb){ private Tuple buildWidgetConnect(final ConnectedBean cb, final String acceptedDomain){
VerticalPanel main = new VerticalPanel(); VerticalPanel main = new VerticalPanel();
main.setWidth("100%"); main.setWidth("100%");
@ -193,7 +197,7 @@ public class ConnectToWidget extends Composite{
VerticalPanel vpLeft = new VerticalPanel(); VerticalPanel vpLeft = new VerticalPanel();
vpLeft.getElement().getStyle().setMarginLeft(15, Unit.PX); vpLeft.getElement().getStyle().setMarginLeft(15, Unit.PX);
vpLeft.setWidth("80%"); vpLeft.setWidth("80%");
Paragraph semanticIdentifier = new Paragraph("Identifier (UUID):"); Paragraph semanticIdentifier = new Paragraph("UUID:");
final TextBox box = new TextBox(); final TextBox box = new TextBox();
final Icon icon = new Icon(IconType.OK_SIGN); final Icon icon = new Icon(IconType.OK_SIGN);
final Anchor view = new Anchor(); final Anchor view = new Anchor();
@ -209,7 +213,7 @@ public class ConnectToWidget extends Composite{
public void onKeyPress(KeyPressEvent event) { public void onKeyPress(KeyPressEvent event) {
GWT.log("onKeyPress " + event.getNativeEvent().getKeyCode()); GWT.log("onKeyPress " + event.getNativeEvent().getKeyCode());
if(!(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_BACKSPACE || event.getNativeEvent().getKeyCode() == KeyCodes.KEY_DELETE)) if(!(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_BACKSPACE || event.getNativeEvent().getKeyCode() == KeyCodes.KEY_DELETE))
validateUUID(box, cb, icon, view); validateUUID(box, cb, icon, view, acceptedDomain);
} }
}); });
box.addChangeHandler(new ChangeHandler() { box.addChangeHandler(new ChangeHandler() {
@ -217,7 +221,7 @@ public class ConnectToWidget extends Composite{
@Override @Override
public void onChange(ChangeEvent event) { public void onChange(ChangeEvent event) {
GWT.log("onChange"); GWT.log("onChange");
validateUUID(box, cb, icon, view); validateUUID(box, cb, icon, view, acceptedDomain);
} }
}); });
box.setWidth("512px"); box.setWidth("512px");
@ -230,8 +234,10 @@ public class ConnectToWidget extends Composite{
vpRight.setWidth("20%"); vpRight.setWidth("20%");
Button removeExtra = new Button(); Button removeExtra = new Button();
removeExtra.setIcon(IconType.MINUS); removeExtra.setText("Remove");
removeExtra.setTitle("Remove this connection"); removeExtra.setType(ButtonType.LINK);
removeExtra.getElement().getStyle().setFontWeight(FontWeight.BOLD);
removeExtra.setTitle("Remove this Connection");
removeExtra.addClickHandler(new ClickHandler() { removeExtra.addClickHandler(new ClickHandler() {
@Override @Override
@ -249,7 +255,6 @@ public class ConnectToWidget extends Composite{
} }
} }
}); });
vpRight.getElement().getStyle().setFloat(Float.RIGHT);
vpRight.add(removeExtra); vpRight.add(removeExtra);
hp.add(vpLeft); hp.add(vpLeft);
hp.add(vpRight); hp.add(vpRight);
@ -260,7 +265,7 @@ public class ConnectToWidget extends Composite{
return new Tuple(cb, main, box); return new Tuple(cb, main, box);
} }
protected void validateUUID(final TextBox box, final ConnectedBean c, final Icon icon, final Anchor view) { protected void validateUUID(final TextBox box, final ConnectedBean c, final Icon icon, final Anchor view, final String acceptedDomain) {
final String currentText = box.getText().trim(); final String currentText = box.getText().trim();
@ -284,13 +289,13 @@ public class ConnectToWidget extends Composite{
icon.setIcon(IconType.ROTATE_RIGHT); icon.setIcon(IconType.ROTATE_RIGHT);
icon.setSpin(true); icon.setSpin(true);
service.checkIdentifierExists(currentText, new AsyncCallback<String>() { service.checkIdentifierExistsInDomain(currentText, acceptedDomain, new AsyncCallback<String>() {
@Override @Override
public void onSuccess(String result) { public void onSuccess(String result) {
if(result != null){ if(result != null){
c.setDestKnowledgeBaseId(currentText); c.setKnowledgeBaseId(currentText);
icon.setType(IconType.OK_CIRCLE); icon.setType(IconType.OK_CIRCLE);
icon.setSpin(false); icon.setSpin(false);
icon.setTitle(""); icon.setTitle("");
@ -324,25 +329,26 @@ public class ConnectToWidget extends Composite{
* @return * @return
*/ */
public List<ConnectedBean> getConnectList() { public List<ConnectedBean> getConnectList() {
TODO //TODO
// List<ConnectedBean> toReturn = new ArrayList<>(); // List<ConnectedBean> toReturn = new ArrayList<>();
// //
// if(currentlyConnected != null) // if(currentlyConnected != null)
// currentlyConnected = new ArrayList<ConnectedBean>(0); // currentlyConnected = new ArrayList<ConnectedBean>(0);
// //
// for (Tuple p : connectList) { // for (Tuple p : connectList) {
// String suggestedIdentifier = ((ConnectedBean)p.getO()).getDestKnowledgeBaseId(); // String suggestedIdentifier = ((ConnectedBean)p.getO()).getDestKnowledgeBaseId();
// if(suggestedIdentifier == null || suggestedIdentifier.isEmpty()) // if(suggestedIdentifier == null || suggestedIdentifier.isEmpty())
// continue; // continue;
// else{ // else{
// ConnectedBean connectedRecord = (ConnectedBean) p.getO(); // ConnectedBean connectedRecord = (ConnectedBean) p.getO();
// connectedRecord.setToBeKept(true); // connectedRecord.setToBeKept(true);
// currentlyConnected.add((ConnectedBean) p.getO()); // currentlyConnected.add((ConnectedBean) p.getO());
// } // }
// } // }
// //
// return currentlyConnected; // return currentlyConnected;
return null;
} }
} }

View File

@ -25,11 +25,7 @@ import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
public class SimilarGRSFRecordWidget extends Composite { public class SimilarGRSFRecordWidget extends Composite {
private static final int THRESHOLD_SET_HIDDEN = 5;
private static final String SEE_MORE = "See More";
private static final String SEE_LESS = "See Less";
private static SimilarGRSFRecordWidgetUiBinder uiBinder = GWT private static SimilarGRSFRecordWidgetUiBinder uiBinder = GWT
.create(SimilarGRSFRecordWidgetUiBinder.class); .create(SimilarGRSFRecordWidgetUiBinder.class);
@ -40,25 +36,21 @@ public class SimilarGRSFRecordWidget extends Composite {
@UiField @UiField
VerticalPanel similarGrsfRecordsPanel; VerticalPanel similarGrsfRecordsPanel;
// @UiField
// VerticalPanel similarGrsfRecordsSuggestedPanel;
//
// @UiField
// Button addSimilarRecord;
@UiField @UiField
Button viewMore; Button viewMore;
// private List<Tuple> extraSimilarRecordsList = new ArrayList<Tuple>(0);
private List<SimilarGRSFRecord> availableGRSFSimilarRecords; private List<SimilarGRSFRecord> availableGRSFSimilarRecords;
private List<Widget> toHide = new ArrayList<Widget>(); private List<Widget> toHide = new ArrayList<Widget>();
//private GRSFManageWidgetServiceAsync service; private static final int THRESHOLD_SET_HIDDEN = 5;
private static final String SEE_MORE = "See More";
private static final String SEE_LESS = "See Less";
/** /**
* Get widget for available similar grsf records * Get widget for available similar grsf records
* @param availableGRSFSimilarRecords * @param availableGRSFSimilarRecords
* @param service * @param service
*/ */
public SimilarGRSFRecordWidget(List<SimilarGRSFRecord> availableGRSFSimilarRecords/*, GRSFManageWidgetServiceAsync service*/) { public SimilarGRSFRecordWidget(List<SimilarGRSFRecord> availableGRSFSimilarRecords) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
//this.service = service; //this.service = service;
@ -133,7 +125,7 @@ public class SimilarGRSFRecordWidget extends Composite {
VerticalPanel leftPanel = new VerticalPanel(); VerticalPanel leftPanel = new VerticalPanel();
leftPanel.setWidth("80%"); leftPanel.setWidth("80%");
leftPanel.getElement().getStyle().setMarginLeft(20, Unit.PX); leftPanel.getElement().getStyle().setMarginLeft(20, Unit.PX);
Paragraph name = new Paragraph("Record name: " + (similarGRSFRecord.getShortName() != null? similarGRSFRecord.getShortName() : "Unavailable")); Paragraph name = new Paragraph("Record Name: " + (similarGRSFRecord.getTitle() != null? similarGRSFRecord.getTitle() : "Unavailable"));
leftPanel.add(name); leftPanel.add(name);
if(similarGRSFRecord.getDescription() != null){ if(similarGRSFRecord.getDescription() != null){
String shortDescrption = similarGRSFRecord.getDescription().length() > 45 ? String shortDescrption = similarGRSFRecord.getDescription().length() > 45 ?
@ -144,7 +136,7 @@ public class SimilarGRSFRecordWidget extends Composite {
description.setTitle("Description: " + similarGRSFRecord.getDescription()); description.setTitle("Description: " + similarGRSFRecord.getDescription());
leftPanel.add(description); leftPanel.add(description);
} }
Paragraph identifier = new Paragraph("Record UUID: " + Paragraph identifier = new Paragraph("UUID: " +
similarGRSFRecord.getKnowledgeBaseId()); similarGRSFRecord.getKnowledgeBaseId());
leftPanel.add(identifier); leftPanel.add(identifier);
@ -162,33 +154,18 @@ public class SimilarGRSFRecordWidget extends Composite {
// add merge checkbox // add merge checkbox
final CheckBox mergeSuggested = new CheckBox("Merge"); final CheckBox mergeSuggested = new CheckBox("Merge");
mergeSuggested.setTitle("Suggest to merge the current record with this similar record"); mergeSuggested.setTitle("Suggest to merge the current record with this similar record");
//mergeSuggested.getElement().getStyle().setPaddingTop(3, Unit.PC);
mergeSuggested.setValue(false); mergeSuggested.setValue(false);
mergeSuggested.addClickHandler(new ClickHandler() { mergeSuggested.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent arg0) { public void onClick(ClickEvent arg0) {
similarGRSFRecord.setSuggestedMerge(mergeSuggested.getValue()); similarGRSFRecord.setSuggestedMerge(mergeSuggested.getValue());
} }
}); });
// final CheckBox removeExtra = new CheckBox("Remove");
// removeExtra.getElement().getStyle().setPaddingTop(3, Unit.PC);
// removeExtra.setTitle("Remove this record among the similar ones");
// removeExtra.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent arg0) {
// similarGRSFRecord.setToBeKept(!removeExtra.getValue());
// }
// });
rightPanel.getElement().getStyle().setFloat(Float.RIGHT); rightPanel.getElement().getStyle().setFloat(Float.RIGHT);
rightPanel.add(mergeSuggested); rightPanel.add(mergeSuggested);
// rightPanel.add(removeExtra);
hp.add(leftPanel); hp.add(leftPanel);
hp.add(rightPanel); hp.add(rightPanel);
hp.getElement().getStyle().setPadding(10, Unit.PX); hp.getElement().getStyle().setPadding(10, Unit.PX);
@ -202,16 +179,6 @@ public class SimilarGRSFRecordWidget extends Composite {
*/ */
public List<SimilarGRSFRecord> getSimilarRecords(){ public List<SimilarGRSFRecord> getSimilarRecords(){
if(availableGRSFSimilarRecords == null)
availableGRSFSimilarRecords = new ArrayList<SimilarGRSFRecord>();
// for (Tuple p : extraSimilarRecordsList) {
// SimilarGRSFRecord similarRecord = ((SimilarGRSFRecord)p.getO());
// if(similarRecord.getKnowledgeBaseId() == null || similarRecord.getKnowledgeBaseId().isEmpty())
// continue;
// availableGRSFSimilarRecords.add((SimilarGRSFRecord) p.getO());
// }
return availableGRSFSimilarRecords; return availableGRSFSimilarRecords;
} }

View File

@ -11,6 +11,7 @@ import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Icon; import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.TextBox; import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Float; import com.google.gwt.dom.client.Style.Float;
@ -56,31 +57,28 @@ public class SuggestMerges extends Composite {
public SuggestMerges(GRSFManageWidgetServiceAsync service) { public SuggestMerges(GRSFManageWidgetServiceAsync service) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.service = service; this.service = service;
// manage the "suggest button" // manage the "suggest button"
addSimilarRecord.setIcon(IconType.PLUS_SIGN); addSimilarRecord.setText("Add Merge");
addSimilarRecord.getElement().getStyle().setFloat(Float.RIGHT); addSimilarRecord.getElement().getStyle().setFontWeight(FontWeight.BOLD);
addSimilarRecord.setTitle("Suggest a Similar Record by using its Identifier (UUID)"); addSimilarRecord.setType(ButtonType.LINK);
addSimilarRecord.getElement().getStyle().setFloat(Float.RIGHT); addSimilarRecord.getElement().getStyle().setFloat(Float.RIGHT);
addSimilarRecord.setTitle("Suggest a Similar Record to merge by using its Identifier (UUID)");
// add handler // add handler
addSimilarRecord.addClickHandler(new ClickHandler() { addSimilarRecord.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent arg0) { public void onClick(ClickEvent arg0) {
SimilarGRSFRecord s = new SimilarGRSFRecord(); SimilarGRSFRecord s = new SimilarGRSFRecord();
// s.setExtra(true);
Widget w = buildWidgetForExtraSimilarRecord(s); Widget w = buildWidgetForExtraSimilarRecord(s);
extraSimilarRecordsList.add(new Tuple(s, w, null)); extraSimilarRecordsList.add(new Tuple(s, w, null));
similarGrsfRecordsSuggestedPanel.add(w); similarGrsfRecordsSuggestedPanel.add(w);
} }
}); });
} }
/** /**
* Builds up a widget for suggested similar grsf records. Changes are performed in place with respect to w and s. * Builds up a widget for suggested similar grsf records. Changes are performed in place with respect to w and s.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* @param w the widget * @param w the widget
* @param s the similar record. * @param s the similar record.
*/ */
@ -98,7 +96,7 @@ public class SuggestMerges extends Composite {
HorizontalPanel textBoxIconContainer = new HorizontalPanel(); HorizontalPanel textBoxIconContainer = new HorizontalPanel();
textBoxIconContainer.setWidth("100%"); textBoxIconContainer.setWidth("100%");
Paragraph identifier = new Paragraph("Identifier (UUID):"); Paragraph identifier = new Paragraph("UUID:");
final TextBox box = new TextBox(); final TextBox box = new TextBox();
final Icon icon = new Icon(IconType.OK_SIGN); final Icon icon = new Icon(IconType.OK_SIGN);
final Anchor view = new Anchor(); final Anchor view = new Anchor();
@ -114,7 +112,7 @@ public class SuggestMerges extends Composite {
public void onKeyPress(KeyPressEvent event) { public void onKeyPress(KeyPressEvent event) {
GWT.log("onKeyPress " + event.getNativeEvent().getKeyCode()); GWT.log("onKeyPress " + event.getNativeEvent().getKeyCode());
if(!(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_BACKSPACE || event.getNativeEvent().getKeyCode() == KeyCodes.KEY_DELETE)) if(!(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_BACKSPACE || event.getNativeEvent().getKeyCode() == KeyCodes.KEY_DELETE))
validateUUID(box, s, icon, view); validateUUID(box, s, icon, view, s.getDomain());
} }
}); });
box.addChangeHandler(new ChangeHandler() { box.addChangeHandler(new ChangeHandler() {
@ -122,38 +120,26 @@ public class SuggestMerges extends Composite {
@Override @Override
public void onChange(ChangeEvent event) { public void onChange(ChangeEvent event) {
GWT.log("onChange"); GWT.log("onChange");
validateUUID(box, s, icon, view); validateUUID(box, s, icon, view, s.getDomain());
} }
}); });
box.setWidth("511px"); box.setWidth("511px");
box.setPlaceholder("Insert the Identifier (UUID) of the suggested record"); box.setPlaceholder("Insert the Identifier (UUID) of the record to be merged");
vpLeft.add(identifier); vpLeft.add(identifier);
textBoxIconContainer.add(box); textBoxIconContainer.add(box);
textBoxIconContainer.add(icon); textBoxIconContainer.add(icon);
vpLeft.add(textBoxIconContainer); vpLeft.add(textBoxIconContainer);
vpLeft.add(view); vpLeft.add(view);
// add merge checkbox // the right side
// final CheckBox mergeSuggested = new CheckBox("Merge");
// mergeSuggested.setTitle("Suggest to merge the current record with this similar record");
// mergeSuggested.getElement().getStyle().setPaddingTop(3, Unit.PC);
// mergeSuggested.setValue(false);
VerticalPanel vpRight = new VerticalPanel(); VerticalPanel vpRight = new VerticalPanel();
vpRight.setWidth("20%"); vpRight.setWidth("20%");
// mergeSuggested.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent arg0) {
// s.setSuggestedMerge(mergeSuggested.getValue());
// }
// });
//
// vpRight.add(mergeSuggested);
Button removeExtra = new Button(); Button removeExtra = new Button();
removeExtra.setIcon(IconType.MINUS); removeExtra.setText("Remove");
removeExtra.setTitle("Remove this suggested merge"); removeExtra.setTitle("Remove this suggested merge");
removeExtra.getElement().getStyle().setFontWeight(FontWeight.BOLD);
removeExtra.setType(ButtonType.LINK);
removeExtra.getElement().getStyle().setFloat(Float.RIGHT); removeExtra.getElement().getStyle().setFloat(Float.RIGHT);
removeExtra.addClickHandler(new ClickHandler() { removeExtra.addClickHandler(new ClickHandler() {
@ -174,7 +160,6 @@ public class SuggestMerges extends Composite {
}); });
vpRight.getElement().getStyle().setFloat(Float.RIGHT); vpRight.getElement().getStyle().setFloat(Float.RIGHT);
vpRight.add(removeExtra); vpRight.add(removeExtra);
// vpRight.add(mergeSuggested);
hp.add(vpLeft); hp.add(vpLeft);
hp.add(vpRight); hp.add(vpRight);
HTML separator = new HTML("<hr style=\"width:100%;\"/>"); HTML separator = new HTML("<hr style=\"width:100%;\"/>");
@ -184,7 +169,15 @@ public class SuggestMerges extends Composite {
return main; return main;
} }
protected void validateUUID(final TextBox box, final SimilarGRSFRecord s, final Icon icon, final Anchor view) { /**
* Validate a UUID (ask at server side if it is ok)
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* @param box
* @param s
* @param icon
* @param view
*/
protected void validateUUID(final TextBox box, final SimilarGRSFRecord s, final Icon icon, final Anchor view, String domain) {
final String currentText = box.getText().trim(); final String currentText = box.getText().trim();
@ -210,7 +203,7 @@ public class SuggestMerges extends Composite {
icon.setIcon(IconType.ROTATE_RIGHT); icon.setIcon(IconType.ROTATE_RIGHT);
icon.setSpin(true); icon.setSpin(true);
service.checkIdentifierExists(currentText, new AsyncCallback<String>() { service.checkIdentifierExistsInDomain(currentText, domain, new AsyncCallback<String>() {
@Override @Override
public void onSuccess(String result) { public void onSuccess(String result) {
@ -248,7 +241,7 @@ public class SuggestMerges extends Composite {
} }
/** /**
* Get the whole of similar records * Get the whole list of similar records
* @return * @return
*/ */
public List<SimilarGRSFRecord> getSimilarRecords(){ public List<SimilarGRSFRecord> getSimilarRecords(){

View File

@ -4,7 +4,7 @@ import com.google.gwt.user.client.ui.Widget;
/** /**
* A class of pair: a widget and an object * A class of elements: two widgets and an object
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class Tuple { public class Tuple {
@ -16,10 +16,18 @@ public class Tuple {
this.w = w; this.w = w;
this.w2 = w2; this.w2 = w2;
} }
public Object getO(){ return o; } public Object
public Widget getW(){ return w; } getO(){
public void setO(Object o){ this.o = o; } return o; }
public void setW(Widget w){ this.w = w; } public Widget getW(){
return w;
}
public void setO(Object o){
this.o = o;
}
public void setW(Widget w){
this.w = w;
}
public Widget getW2() { public Widget getW2() {
return w2; return w2;
} }

View File

@ -28,10 +28,10 @@ import org.gcube.vomanagement.usermanagement.RoleManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager; import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
import org.gcube.vomanagement.usermanagement.model.GCubeTeam; import org.gcube.vomanagement.usermanagement.model.GCubeTeam;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import eu.trentorise.opendata.jackan.internal.org.apache.http.impl.client.CloseableHttpClient; import eu.trentorise.opendata.jackan.internal.org.apache.http.impl.client.CloseableHttpClient;
import eu.trentorise.opendata.jackan.internal.org.apache.http.impl.client.HttpClientBuilder; import eu.trentorise.opendata.jackan.internal.org.apache.http.impl.client.HttpClientBuilder;
@ -46,8 +46,8 @@ import eu.trentorise.opendata.jackan.model.CkanResource;
public class GRSFNotificationService extends RemoteServiceServlet implements GRSFManageWidgetService{ public class GRSFNotificationService extends RemoteServiceServlet implements GRSFManageWidgetService{
private static final long serialVersionUID = -4534905087994875893L; private static final long serialVersionUID = -4534905087994875893L;
//private static final Log logger = LogFactoryUtil.getLog(GRSFNotificationService.class); private static final Log logger = LogFactoryUtil.getLog(GRSFNotificationService.class);
private static final Logger logger = LoggerFactory.getLogger(GRSFNotificationService.class); //private static final Logger logger = LoggerFactory.getLogger(GRSFNotificationService.class);
/** /**
* Instanciate the ckan util library. * Instanciate the ckan util library.
@ -64,7 +64,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
logger.debug("Discovering ckan utils library into scope " + scopeInWhichDiscover); logger.debug("Discovering ckan utils library into scope " + scopeInWhichDiscover);
instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover); instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
}catch(Exception e){ }catch(Exception e){
logger.error("Unable to retrieve ckan utils. Error was " + e.toString()); logger.error("Unable to retrieve ckan utils. Error was ", e);
throw e; throw e;
} }
return instance; return instance;
@ -75,7 +75,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
ManageProductBean toReturn = null; ManageProductBean toReturn = null;
// check into session first // check into user's session first
HttpSession httpSession = getThreadLocalRequest().getSession(); HttpSession httpSession = getThreadLocalRequest().getSession();
String sessionProductKey = ScopeProvider.instance.get() + productIdentifier; String sessionProductKey = ScopeProvider.instance.get() + productIdentifier;
if(httpSession.getAttribute(sessionProductKey) != null) if(httpSession.getAttribute(sessionProductKey) != null)
@ -86,15 +86,30 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
toReturn = new ManageProductBean(); toReturn = new ManageProductBean();
toReturn.setCatalogueIdentifier(UUID.randomUUID().toString()); toReturn.setCatalogueIdentifier(UUID.randomUUID().toString());
List<ConnectedBean> connectTo = new ArrayList<>(); List<ConnectedBean> connectTo = new ArrayList<>();
// these are the records alread connected
connectTo.add(new ConnectedBean( connectTo.add(new ConnectedBean(
"89f1e413-dc9f-3b4e-b1c5-0e8560177254", "uuid-of-a-connected-bean",
"Random title", "Random description",
"http://data.d4science.org/ctlg/GRSF_Admin/89f1e413-dc9f-3b4e-b1c5-0e8560177254", "Random shortName",
"Fishery", "Random Title",
"ajklsdkad:akljdnajdna" "http://data.d4science.org/ctlg/GRSF_Admin/uuid-of-a-connected-bean",
"semantic identifier of the record",
"Fishery"
)); ));
toReturn.setCurrentConnections(connectTo); toReturn.setCurrentConnections(connectTo);
// these are the "suggested connections"
List<ConnectedBean> suggestionsForConnections = new ArrayList<>();
suggestionsForConnections.add(new ConnectedBean(
"uuid-of-a-connected-bean-suggested",
"Random description",
"Random shortName",
"Random Title",
"http://data.d4science.org/ctlg/GRSF_Admin/uuid-of-a-connected-bean-suggested",
"semantic identifier of the record suggested for connection",
"Fishery"
));
toReturn.setSuggestedByKnowledgeBaseConnections(suggestionsForConnections);
toReturn.setGrsfDomain("Stock"); toReturn.setGrsfDomain("Stock");
toReturn.setGrsfType("Assessment Unit"); toReturn.setGrsfType("Assessment Unit");
toReturn.setKnowledgeBaseIdentifier("91f1e413-dc9f-3b4e-b1c5-0e8560177253"); toReturn.setKnowledgeBaseIdentifier("91f1e413-dc9f-3b4e-b1c5-0e8560177253");
@ -110,16 +125,60 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
sources.add(new SourceRecord("FishSource", "http://www.google.it")); sources.add(new SourceRecord("FishSource", "http://www.google.it"));
toReturn.setSources(sources); toReturn.setSources(sources);
List<SimilarGRSFRecord> similarGrsfRecords = new ArrayList<SimilarGRSFRecord>(); List<SimilarGRSFRecord> similarGrsfRecords = new ArrayList<SimilarGRSFRecord>();
similarGrsfRecords.add(new SimilarGRSFRecord("same species overlapping water areas", similarGrsfRecords.add(new SimilarGRSFRecord(
Utils.getDatasetKnowledgeBaseIdFromUrl("http://data.d4science.org/ctlg/GRSF_Admin/1a03d6d8-002d-39b9-9255-a954c8ee2bf0") "uuid-similar-record-1",
,"unknown:ONCORHYNCHUS GORBUSCHA+unknown:USA-AKSTATE-KELPB", "description similar record",
"Pink Salmon Kelp By (District112)", "short name similar record 1",
"http://data.d4science.org/ctlg/GRSF_Admin/1a03d6d8-002d-39b9-9255-a954c8ee2bf0")); "title similar record 1",
similarGrsfRecords.add(new SimilarGRSFRecord("same species overlapping water areas 2", "http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-1",
Utils.getDatasetKnowledgeBaseIdFromUrl("http://data.d4science.org/ctlg/GRSF_Admin/1a03d6d8-002d-39b9-9255-a954c8ee2bf0"), "semantic identifier record 1",
"unknown:ONCORHYNCHUS GORBUSCHA+unknown:USA-AKSTATE-KELPB", "Stock 1"
"Pink Salmon Kelp By (District112) 2", ));
"http://data.d4science.org/ctlg/GRSF_Admin/1a03d6d8-002d-39b9-9255-a954c8ee2bf0")); similarGrsfRecords.add(new SimilarGRSFRecord(
"uuid-similar-record-2",
"description similar record",
"short name similar record 2",
"title similar record 2",
"http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-2",
"semantic identifier record 2",
"Stock 2"
));
similarGrsfRecords.add(new SimilarGRSFRecord(
"uuid-similar-record-3",
"description similar record",
"short name similar record 3",
"title similar record 3",
"http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-3",
"semantic identifier record 3",
"Stock 3"
));
similarGrsfRecords.add(new SimilarGRSFRecord(
"uuid-similar-record-4",
"description similar record",
"short name similar record 4",
"title similar record 4",
"http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-4",
"semantic identifier record 4",
"Stock 4"
));
similarGrsfRecords.add(new SimilarGRSFRecord(
"uuid-similar-record-5",
"description similar record",
"short name similar record 5",
"title similar record 5",
"http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-5",
"semantic identifier record 5",
"Stock 5"
));
similarGrsfRecords.add(new SimilarGRSFRecord(
"uuid-similar-record-6",
"description similar record",
"short name similar record 6",
"title similar record 6",
"http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-6",
"semantic identifier record 6",
"Stock 6"
));
toReturn.setSimilarGrsfRecords(similarGrsfRecords); toReturn.setSimilarGrsfRecords(similarGrsfRecords);
}else{ }else{
@ -140,12 +199,9 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
// check it is a grsf record (Source records have a different System Type) // check it is a grsf record (Source records have a different System Type)
Map<String, String> extrasAsMap = record.getExtrasAsHashMap(); Map<String, String> extrasAsMap = record.getExtrasAsHashMap();
// get extras as hashmap and pairs
List<CkanPair> extrasAsPairs = record.getExtras();
String systemType = extrasAsMap.get(Constants.SYSTEM_TYPE_CUSTOM_KEY); String systemType = extrasAsMap.get(Constants.SYSTEM_TYPE_CUSTOM_KEY);
if(systemType == null || systemType.isEmpty() || systemType.equals(Constants.SYSTEM_TYPE_FOR_SOURCES_VALUE)) if(systemType == null || systemType.isEmpty() || systemType.equals(Constants.SYSTEM_TYPE_FOR_SOURCES_VALUE))
throw new NoGRSFRecordException("This is not a GRSF Record"); throw new NoGRSFRecordException("This is not a GRSF Record");
boolean isStock = record.getExtrasAsHashMap().get(Constants.DOMAIN_CUSTOM_KEY).contains(Product_Type.STOCK.getOrigName()); boolean isStock = record.getExtrasAsHashMap().get(Constants.DOMAIN_CUSTOM_KEY).contains(Product_Type.STOCK.getOrigName());
@ -154,22 +210,14 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
Utils.getFieldToFieldNameSpaceMapping(httpSession, isStock ? Utils.getFieldToFieldNameSpaceMapping(httpSession, isStock ?
Constants.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_STOCK : Constants.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_FISHERY); Constants.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_STOCK : Constants.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_FISHERY);
// get extras as pairs
List<CkanPair> extrasAsPairs = record.getExtras();
Map<String, List<String>> extrasWithoutNamespaces = Utils.replaceFieldsKey(extrasAsPairs, fieldsNamespacesMap); Map<String, List<String>> extrasWithoutNamespaces = Utils.replaceFieldsKey(extrasAsPairs, fieldsNamespacesMap);
// get extras fields (wrt the mandatory ones) to show in the management panel TODO
// Utils.getExtrasToShow();
String catalogueIdentifier = record.getId(); String catalogueIdentifier = record.getId();
Status status = Status.fromString(extrasWithoutNamespaces.get(Constants.STATUS_OF_THE_GRSF_RECORD_CUSTOM_KEY).get(0)); Status status = Status.fromString(extrasWithoutNamespaces.get(Constants.STATUS_OF_THE_GRSF_RECORD_CUSTOM_KEY).get(0));
String uuidKB = extrasWithoutNamespaces.get(Constants.UUID_KB_CUSTOM_KEY).get(0); String uuidKB = extrasWithoutNamespaces.get(Constants.UUID_KB_CUSTOM_KEY).get(0);
String grsfDomain = extrasWithoutNamespaces.get(Constants.DOMAIN_CUSTOM_KEY).get(0); String grsfDomain = extrasWithoutNamespaces.get(Constants.DOMAIN_CUSTOM_KEY).get(0);
if(status == null || uuidKB == null)
throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge base uuid = " + uuidKB +
", and grsf domain is = " + grsfDomain);
if(status.equals(Status.To_be_Merged) || status.equals(Status.Rejected))
throw new Exception("Records under merging activity or rejected cannot be updated");
String semanticId = extrasWithoutNamespaces.get(Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY).get(0); String semanticId = extrasWithoutNamespaces.get(Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY).get(0);
String shortName = extrasWithoutNamespaces.get(Constants.SHORT_NAME_CUSTOM_KEY).get(0); String shortName = extrasWithoutNamespaces.get(Constants.SHORT_NAME_CUSTOM_KEY).get(0);
String grsfType = extrasWithoutNamespaces.get(Constants.GRSF_TYPE_CUSTOM_KEY).get(0); String grsfType = extrasWithoutNamespaces.get(Constants.GRSF_TYPE_CUSTOM_KEY).get(0);
@ -179,18 +227,21 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
try{ try{
traceabilityFlag = extrasWithoutNamespaces.get(Constants.TRACEABILITY_FLAG_CUSTOM_KEY).get(0).equalsIgnoreCase("true"); traceabilityFlag = extrasWithoutNamespaces.get(Constants.TRACEABILITY_FLAG_CUSTOM_KEY).get(0).equalsIgnoreCase("true");
}catch(Exception e){ }catch(Exception e){
logger.warn("Unable to fetch traceability flag", e); logger.warn("Unable to fetch traceability flag. Setting it to false", e);
} }
if(status.equals(Status.To_be_Merged) || status.equals(Status.Rejected))
throw new Exception("Records under merging activity or rejected cannot be managed!");
// Get similar GRSF records, if any (each of which should have name, description, url and id(i.e semantic identifier)) // Get similar GRSF records, if any (each of which should have name, description, url and id(i.e semantic identifier))
List<String> similarGrsfRecordsAsStrings = extrasWithoutNamespaces.containsKey(Constants.SIMILAR_GRSF_RECORDS_CUSTOM_KEY) ? extrasWithoutNamespaces.get(Constants.SIMILAR_GRSF_RECORDS_CUSTOM_KEY): null; List<String> similarGrsfRecordsAsStrings = extrasWithoutNamespaces.containsKey(Constants.SIMILAR_GRSF_RECORDS_CUSTOM_KEY) ? extrasWithoutNamespaces.get(Constants.SIMILAR_GRSF_RECORDS_CUSTOM_KEY): null;
List<SimilarGRSFRecord> similarRecords = new ArrayList<SimilarGRSFRecord>(0); List<SimilarGRSFRecord> similarRecords = new ArrayList<SimilarGRSFRecord>(0);
if(similarGrsfRecordsAsStrings != null){ if(similarGrsfRecordsAsStrings != null && !similarGrsfRecordsAsStrings.isEmpty()){
for (String similarGRSFRecord : similarGrsfRecordsAsStrings) { if(!similarGrsfRecordsAsStrings.get(0).equals(Constants.NO_SIMILAR_GRSF_RECORDS)){
if(similarGRSFRecord.equals(Constants.NO_SIMILAR_GRSF_RECORDS)) // stop here if there is a single element with this information for (String similarGRSFRecord : similarGrsfRecordsAsStrings) {
break; similarRecords.add(Utils.similarGRSFRecordFromJson(similarGRSFRecord, catalogue, apiKey));
similarRecords.add(Utils.similarGRSFRecordFromJson(similarGRSFRecord)); }
} }
} }
@ -201,13 +252,13 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
extrasWithoutNamespaces.containsKey(Constants.CONNECTED_CUSTOM_KEY) ? extrasWithoutNamespaces.get(Constants.CONNECTED_CUSTOM_KEY): null; extrasWithoutNamespaces.containsKey(Constants.CONNECTED_CUSTOM_KEY) ? extrasWithoutNamespaces.get(Constants.CONNECTED_CUSTOM_KEY): null;
List<ConnectedBean> connectedBeans = new ArrayList<ConnectedBean>(0); List<ConnectedBean> connectedBeans = new ArrayList<ConnectedBean>(0);
if(connectedBeanUrls != null){ if(connectedBeanUrls != null && !connectedBeanUrls.isEmpty()){
for (String connectedBean : connectedBeanUrls) { if(!connectedBeanUrls.get(0).equals(Constants.NO_CONNECTED_RECORDS)){
if(connectedBean.equals(Constants.NO_CONNECTED_RECORDS)) // stop here if there is a single element with this information for (String connectedBean : connectedBeanUrls) {
break; ConnectedBean builtBean = Utils.connectedBeanRecordFromUrl(connectedBean, catalogue, apiKey, httpSession);
ConnectedBean builtBean = Utils.connectedBeanRecordFromUrl(connectedBean, catalogue, apiKey, httpSession); if(builtBean != null)
if(builtBean != null) connectedBeans.add(builtBean);
connectedBeans.add(builtBean); }
} }
} }
@ -218,7 +269,8 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
List<String> exploitedResourcesUrls = isStock ? List<String> exploitedResourcesUrls = isStock ?
(extrasWithoutNamespaces.containsKey(Constants.EXPLOITING_FISHERY_JSON_KEY) ? (extrasWithoutNamespaces.containsKey(Constants.EXPLOITING_FISHERY_JSON_KEY) ?
extrasWithoutNamespaces.get(Constants.EXPLOITING_FISHERY_JSON_KEY) : null): extrasWithoutNamespaces.get(Constants.EXPLOITING_FISHERY_JSON_KEY) : null):
(extrasWithoutNamespaces.containsKey(Constants.RESOURCES_EXPLOITED_JSON_KEY) ? extrasWithoutNamespaces.get(Constants.RESOURCES_EXPLOITED_JSON_KEY) : null); (extrasWithoutNamespaces.containsKey(Constants.RESOURCES_EXPLOITED_JSON_KEY) ?
extrasWithoutNamespaces.get(Constants.RESOURCES_EXPLOITED_JSON_KEY) : null);
if(exploitedResourcesUrls != null && !exploitedResourcesUrls.isEmpty()){ if(exploitedResourcesUrls != null && !exploitedResourcesUrls.isEmpty()){
for (String exploited : exploitedResourcesUrls) { for (String exploited : exploitedResourcesUrls) {
@ -239,15 +291,20 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
} }
// set the values // set the values
toReturn = new ManageProductBean(semanticId, catalogueIdentifier, uuidKB, grsfType, toReturn = new ManageProductBean(
grsfDomain, grsfName, shortName, traceabilityFlag, status, recordUrl, semanticId, catalogueIdentifier, uuidKB, grsfType,
null, sources, similarRecords, connectedBeans, suggestedConnectionsByKnowledgeBase); grsfDomain, grsfName, shortName, traceabilityFlag,
status, recordUrl, sources, similarRecords,
connectedBeans, suggestedConnectionsByKnowledgeBase);
} }
} }
logger.info("Returning item bean " + toReturn); // save it into session
httpSession.setAttribute(sessionProductKey, toReturn); if(toReturn != null)
httpSession.setAttribute(sessionProductKey, toReturn);
logger.debug("Returning item bean " + toReturn);
return toReturn; return toReturn;
} }
@ -268,8 +325,8 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
String username = pContext.getCurrentUser(getThreadLocalRequest()).getUsername(); String username = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
long userId = pContext.getCurrentUser(getThreadLocalRequest()).getUserId(); long userId = pContext.getCurrentUser(getThreadLocalRequest()).getUserId();
long groupId = pContext.getCurrentGroupId(getThreadLocalRequest()); long groupId = pContext.getCurrentGroupId(getThreadLocalRequest());
List<GCubeTeam> teamRoles = roleManager.listTeamsByUserAndGroup(userId, groupId); List<GCubeTeam> teamRolesByUser = roleManager.listTeamsByUserAndGroup(userId, groupId);
toSetInSession = isEditor(username, teamRoles) | isReviewer(username, teamRoles); toSetInSession = isEditor(username, teamRolesByUser) | isReviewer(username, teamRolesByUser);
} }
getThreadLocalRequest().getSession().setAttribute(Constants.GRSF_ADMIN_SESSION_KEY, toSetInSession); getThreadLocalRequest().getSession().setAttribute(Constants.GRSF_ADMIN_SESSION_KEY, toSetInSession);
return toSetInSession; return toSetInSession;
@ -281,7 +338,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
} }
@Override @Override
public String notifyProductUpdate(ManageProductBean bean, List<String> hashtags) throws Exception{ public String notifyProductUpdate(ManageProductBean bean) throws Exception{
logger.info("Creating notification for the bean " + bean + " to send to the knowledge base"); logger.info("Creating notification for the bean " + bean + " to send to the knowledge base");
try{ try{
@ -291,6 +348,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
DataCatalogue catalogue = getCatalogue(context); DataCatalogue catalogue = getCatalogue(context);
String administratorFullName = Utils.getCurrentUser(getThreadLocalRequest()).getFullname(); String administratorFullName = Utils.getCurrentUser(getThreadLocalRequest()).getFullname();
String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername(); String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername();
// check if the base url of the service is in session // check if the base url of the service is in session
String keyPerContext = UtilMethods.concatenateSessionKeyScope(Constants.GRSF_UPDATER_SERVICE, context); String keyPerContext = UtilMethods.concatenateSessionKeyScope(Constants.GRSF_UPDATER_SERVICE, context);
HttpServletRequest threadRequest = getThreadLocalRequest(); HttpServletRequest threadRequest = getThreadLocalRequest();
@ -305,7 +363,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
threadRequest.getSession().removeAttribute(sessionProductKey); threadRequest.getSession().removeAttribute(sessionProductKey);
return Utils.updateRecord(baseUrl, bean, catalogue, username, administratorFullName, threadRequest, return Utils.updateRecord(baseUrl, bean, catalogue, username, administratorFullName, threadRequest,
PortalContext.getConfiguration().getCurrentGroupId(threadRequest), context, token, hashtags); PortalContext.getConfiguration().getCurrentGroupId(threadRequest), context, token, bean.getReport());
}catch(Exception e){ }catch(Exception e){
logger.error("Unable to update the product", e); logger.error("Unable to update the product", e);
@ -324,10 +382,10 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
String fullName = user.getFullname(); String fullName = user.getFullname();
long userId = pContext.getCurrentUser(getThreadLocalRequest()).getUserId(); long userId = pContext.getCurrentUser(getThreadLocalRequest()).getUserId();
long groupId = pContext.getCurrentGroupId(getThreadLocalRequest()); long groupId = pContext.getCurrentGroupId(getThreadLocalRequest());
List<GCubeTeam> teamRoles = roleManager.listTeamsByUserAndGroup(userId, groupId); List<GCubeTeam> teamRolesByUser = roleManager.listTeamsByUserAndGroup(userId, groupId);
boolean isEditor = isEditor(username, teamRoles); boolean isEditor = isEditor(username, teamRolesByUser);
boolean isReviewer = isReviewer(username, teamRoles); boolean isReviewer = isReviewer(username, teamRolesByUser);
if(!(isEditor | isReviewer)) if(!(isEditor | isReviewer))
throw new Exception("You are not allowed to perform this operation!"); throw new Exception("You are not allowed to perform this operation!");
@ -337,7 +395,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
String adminInUrl = decryptedUrl.getAdmin(); String adminInUrl = decryptedUrl.getAdmin();
String uuid = decryptedUrl.getUuid(); String uuid = decryptedUrl.getUuid();
logger.info("User " + username + " has requested to invert an operation on record with id " + uuid + " and admin in url was " + adminInUrl); logger.info("User " + username + " has requested to invert an operation on record with id " + uuid + " and admin in url is " + adminInUrl);
// we need to check the timestamp (it has 24h validity) // we need to check the timestamp (it has 24h validity)
boolean isValidTimestamp = decryptedUrl.isTimestampValid(); boolean isValidTimestamp = decryptedUrl.isTimestampValid();
@ -379,9 +437,9 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
* @param teamRoles * @param teamRoles
* @return true if he/she is an editor, false otherwise * @return true if he/she is an editor, false otherwise
*/ */
private boolean isEditor(String username, List<GCubeTeam> teamRoles){ private boolean isEditor(String username, List<GCubeTeam> teamRolesByUser){
for (GCubeTeam team : teamRoles) { for (GCubeTeam team : teamRolesByUser) {
if(team.getTeamName().equals(Constants.GRSF_CATALOGUE_EDITOR_ROLE)){ if(team.getTeamName().equals(Constants.GRSF_CATALOGUE_EDITOR_ROLE)){
logger.info("User " + username + " is allowed to modify GRSF records as editor"); logger.info("User " + username + " is allowed to modify GRSF records as editor");
return true; return true;
@ -396,9 +454,9 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
* @param teamRoles * @param teamRoles
* @return true if he/she is an reviewer, false otherwise * @return true if he/she is an reviewer, false otherwise
*/ */
private boolean isReviewer(String username, List<GCubeTeam> teamRoles){ private boolean isReviewer(String username, List<GCubeTeam> teamRolesByUser){
for (GCubeTeam team : teamRoles) { for (GCubeTeam team : teamRolesByUser) {
if(team.getTeamName().equals(team.getTeamName().equals(Constants.GRSF_CATALOGUE_REVIEWER_ROLE))){ if(team.getTeamName().equals(team.getTeamName().equals(Constants.GRSF_CATALOGUE_REVIEWER_ROLE))){
logger.info("User " + username + " is allowed to modify GRSF records as reviewer"); logger.info("User " + username + " is allowed to modify GRSF records as reviewer");
return true; return true;
@ -415,7 +473,11 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername(); String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername();
CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username)); CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username));
if(dataset == null) if(dataset == null)
throw new Exception("A record with id " + id + " doesn't exist"); throw new Exception("A GRSF record with id " + id + " doesn't exist");
if(!dataset.getOrganization().getName().equals(Constants.GRSF_ADMIN_ORGANIZATION_NAME))
throw new Exception("The suggested record is not a GRSF record");
return dataset.getExtrasAsHashMap().get(Constants.ITEM_URL_FIELD); return dataset.getExtrasAsHashMap().get(Constants.ITEM_URL_FIELD);
} }
@ -426,9 +488,13 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl); DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl);
String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername(); String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername();
CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username)); CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username));
if(dataset == null) if(dataset == null)
throw new Exception("A record with id " + id + " doesn't exist"); throw new Exception("A record with id " + id + " doesn't exist");
if(!dataset.getOrganization().getName().equals(Constants.GRSF_ADMIN_ORGANIZATION_NAME))
throw new Exception("The suggested record is not a GRSF record");
List<CkanPair> extrasAsPairs = dataset.getExtras(); List<CkanPair> extrasAsPairs = dataset.getExtras();
for (CkanPair ckanPair : extrasAsPairs) { for (CkanPair ckanPair : extrasAsPairs) {
@ -438,39 +504,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
} }
} }
throw new Exception("A record with id " + id + " doesn't exist in domain " + domain); throw new Exception("A GRSF record with id " + id + " doesn't exist in domain " + domain);
} }
// @Override
// public boolean checkSemanticIdentifierExists(String semanticIdentifier)
// throws Exception {
//
// return getDataset(semanticIdentifier) != null;
// }
//
// @Override
// public boolean checkSemanticIdentifierExistsInDomain(String semanticIdentifier, String domain)
// throws Exception {
// CkanDataset dataset = getDataset(semanticIdentifier);
//
// // look for the right domain this time
// List<CkanPair> extrasAsPairs = dataset.getExtras();
//
// for (CkanPair ckanPair : extrasAsPairs) {
// if(ckanPair.getKey().contains(Constants.DOMAIN_CUSTOM_KEY)){
// return ckanPair.getValue().equalsIgnoreCase(domain);
// }
// }
//
// return false;
// }
// private CkanDataset getDataset(String semanticIdentifier) throws Exception{
// String scopePerCurrentUrl = Utils.getScopeFromClientUrl(getThreadLocalRequest());
// DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl);
// String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername();
// CkanDataset dataset = Utils.getRecordBySemanticIdentifier(semanticIdentifier, catalogue, catalogue.getApiKeyFromUsername(username));
// return dataset;
// }
} }

View File

@ -123,7 +123,7 @@ public class GRSFUpdaterServiceClient {
JSONObject cc = new JSONObject(); JSONObject cc = new JSONObject();
if(c.isRemove() || (c.isConnect() && !c.isRemove())){ // do not send it if it needs to be unconnected but not removed if(c.isRemove() || (c.isConnect() && !c.isRemove())){ // do not send it if it needs to be unconnected but not removed
cc.put(Constants.SOURCE_KNOWLEDGE_BASE_ID, bean.getKnowledgeBaseIdentifier()); cc.put(Constants.SOURCE_KNOWLEDGE_BASE_ID, bean.getKnowledgeBaseIdentifier());
cc.put(Constants.DEST_KNOWLEDGE_BASE_ID, c.getDestKnowledgeBaseId()); cc.put(Constants.DEST_KNOWLEDGE_BASE_ID, c.getKnowledgeBaseId());
cc.put(Constants.SOURCE_DOMAIN, bean.getGrsfDomain()); cc.put(Constants.SOURCE_DOMAIN, bean.getGrsfDomain());
cc.put(Constants.CONNECTION_TO_REMOVE, c.isRemove()); cc.put(Constants.CONNECTION_TO_REMOVE, c.isRemove());
} }

View File

@ -130,7 +130,7 @@ public class SocialCommunications {
* @param enablePostNotification * @param enablePostNotification
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static void writeProductPost(ManageProductBean bean, String username, String fullName, List<String> hashtags, boolean enablePostNotification){ public static void writeProductPost(ManageProductBean bean, String username, String fullName, String report, boolean enablePostNotification){
// discover service endpoint for the social networking library // discover service endpoint for the social networking library
String currentScope = ScopeProvider.instance.get(); String currentScope = ScopeProvider.instance.get();
@ -177,13 +177,14 @@ public class SocialCommunications {
// replace // replace
String message = POST_MESSAGE.replace("PRODUCT_TITLE", bean.getGrsfName()).replace("PRODUCT_URL", bean.getRecordUrl()).replace("USER_FULLNAME", fullName); String message = POST_MESSAGE.replace("PRODUCT_TITLE", bean.getGrsfName()).replace("PRODUCT_URL", bean.getRecordUrl()).replace("USER_FULLNAME", fullName);
if(hashtags != null && !hashtags.isEmpty()) // evaluate hashtags from the report ... TODO
for (String hashtag : hashtags) { // if(hashtags != null && !hashtags.isEmpty())
String modifiedHashtag = hashtag.replaceAll(" ", "_").replace("_+", "_"); // no empty spaces allowed // for (String hashtag : hashtags) {
if(modifiedHashtag.endsWith("_")) // String modifiedHashtag = hashtag.replaceAll(" ", "_").replace("_+", "_"); // no empty spaces allowed
modifiedHashtag = modifiedHashtag.substring(0, modifiedHashtag.length() - 1); // if(modifiedHashtag.endsWith("_"))
message += " #" + modifiedHashtag; // modifiedHashtag = modifiedHashtag.substring(0, modifiedHashtag.length() - 1);
} // message += " #" + modifiedHashtag;
// }
logger.info("The post that is going to be written is -> " + message); logger.info("The post that is going to be written is -> " + message);
postRequest = new HttpPost(basePath + SOCIAL_SERVICE_WRITE_APPLICATION_POST + "?gcube-token=" + applicationToken); postRequest = new HttpPost(basePath + SOCIAL_SERVICE_WRITE_APPLICATION_POST + "?gcube-token=" + applicationToken);

View File

@ -6,10 +6,8 @@ import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -25,7 +23,6 @@ import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datacatalogue.ckanutillibrary.server.ApplicationProfileScopePerUrlReader; import org.gcube.datacatalogue.ckanutillibrary.server.ApplicationProfileScopePerUrlReader;
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueRunningCluster; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueRunningCluster;
import org.gcube.datacatalogue.ckanutillibrary.shared.ex.ApplicationProfileNotFoundException;
import org.gcube.datacatalogue.common.Constants; import org.gcube.datacatalogue.common.Constants;
import org.gcube.datacatalogue.common.enums.Product_Type; import org.gcube.datacatalogue.common.enums.Product_Type;
import org.gcube.datacatalogue.common.enums.Status; import org.gcube.datacatalogue.common.enums.Status;
@ -58,62 +55,9 @@ import eu.trentorise.opendata.jackan.model.CkanPair;
*/ */
public class Utils { public class Utils {
private static final String GENERIC_RESOURCE_NAME = "GRSFManageEntries";
private static final String GENERIC_RESOURCE_SECONDARY_TYPE = "ApplicationProfile";
private static final Logger logger = LoggerFactory.getLogger(Utils.class); private static final Logger logger = LoggerFactory.getLogger(Utils.class);
private static final String REGEX_UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; private static final String REGEX_UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
/**
* Look up from the IS other information that can be potentially displayed in read only mode in the management panel.
* @return a list of extra keys to show.
*/
public static Set<String> getLookedUpExtrasKeys() {
Set<String> lookedUpExtrasKeys = new HashSet<String>();
String scope = ScopeProvider.instance.get();
logger.debug("Trying to fetch applicationProfile profile from the infrastructure for " + GENERIC_RESOURCE_NAME + " scope: " + scope);
try {
Query q = new QueryBox("for $profile in collection('/db/Profiles/GenericResource')//Resource " +
"where $profile/Profile/SecondaryType/string() eq '"+ GENERIC_RESOURCE_SECONDARY_TYPE + "' and $profile/Profile/Name/string() " +
" eq '" + GENERIC_RESOURCE_NAME + "'" +
"return $profile");
DiscoveryClient<String> client = client();
List<String> appProfile = client.submit(q);
if (appProfile == null || appProfile.size() == 0)
throw new ApplicationProfileNotFoundException("Your applicationProfile is not registered in the infrastructure");
else {
String elem = appProfile.get(0);
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node node = docBuilder.parse(new InputSource(new StringReader(elem))).getDocumentElement();
XPathHelper helper = new XPathHelper(node);
List<String> currValue = null;
currValue = helper.evaluate("/Resource/Profile/Body/text()");
if (currValue != null && currValue.size() > 0) {
String body = currValue.get(0);
String[] splittedSet = body.split(",");
if(splittedSet != null && splittedSet.length > 0)
for (String entry : splittedSet) {
String trimmed = entry.trim();
if(trimmed.isEmpty())
continue;
lookedUpExtrasKeys.add(trimmed);
}
}
}
logger.info("Extras entries are " + lookedUpExtrasKeys);
return lookedUpExtrasKeys;
} catch (Exception e) {
logger.error("Error while trying to fetch applicationProfile profile from the infrastructure", e);
return null;
}
}
/** /**
* Return a map for converting a key to a namespace:key format by reading a generic resource. * Return a map for converting a key to a namespace:key format by reading a generic resource.
* @param httpSession * @param httpSession
@ -243,7 +187,7 @@ public class Utils {
long groupId, long groupId,
String context, String context,
String token, String token,
List<String> hashtags) throws Exception{ String report) throws Exception{
if(serviceUrl == null) if(serviceUrl == null)
throw new IllegalArgumentException("GRSF Updater service url cannot be null"); throw new IllegalArgumentException("GRSF Updater service url cannot be null");
@ -260,7 +204,7 @@ public class Utils {
// send update to the knowledge base // send update to the knowledge base
GRSFUpdaterServiceClient.updateKB(httpClient, serviceUrl, bean, catalogue, username, fullName); GRSFUpdaterServiceClient.updateKB(httpClient, serviceUrl, bean, catalogue, username, fullName);
// manage interactions through a separated thread but set there security token and context // manage interactions through a separated thread but set there security token and context (and then reset them)
new Thread(()->{ new Thread(()->{
ScopeProvider.instance.set(context); ScopeProvider.instance.set(context);
@ -271,10 +215,13 @@ public class Utils {
SocialCommunications.sendEmailAdministrators(bean, catalogue, username, fullName, groupId, httpServletRequest, bean.isMergesInvolved()); SocialCommunications.sendEmailAdministrators(bean, catalogue, username, fullName, groupId, httpServletRequest, bean.isMergesInvolved());
// create a post about the operation // create a post about the operation
SocialCommunications.writeProductPost(bean, username, fullName, hashtags, true); SocialCommunications.writeProductPost(bean, username, fullName, report, true);
}catch(Exception e){ }catch(Exception e){
logger.error("Something failed while alerting editors/reviewers", e); logger.error("Something failed while alerting editors/reviewers", e);
}finally{
ScopeProvider.instance.reset();
SecurityTokenProvider.instance.reset();
} }
}).start(); }).start();
@ -396,50 +343,6 @@ public class Utils {
return user; return user;
} }
// /**
// * Given a semantic identifier, check if a record exists and return it
// * @param suggestedRecordSemanticIdentifier
// * @param catalogue
// * @return CkanDataset
// * @throws Exception in case no record matches the semantic identifier
// */
// public static CkanDataset getRecordBySemanticIdentifier(
// String suggestedRecordSemanticIdentifier, DataCatalogue catalogue,
// String apiKey) throws Exception {
//
// if(suggestedRecordSemanticIdentifier == null || suggestedRecordSemanticIdentifier.isEmpty())
// throw new Exception(Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY + " cannot be null or emtpy");
//
// String query = Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY + "\"" + suggestedRecordSemanticIdentifier+ "\"";
// List<CkanDataset> datasets = catalogue.searchForPackageInOrganization(apiKey, query, 0, 10, Constants.GRSF_ADMIN_ORGANIZATION_NAME);
//
// if(datasets == null || datasets.isEmpty()){
// String message = "Unable to find dataset with such " + Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY;
// logger.warn(message);
// throw new Exception(message);
// }
//
// logger.info("Result size is " + datasets.size());
//
// if(datasets.size() == 1)
// return datasets.get(0);
// else{
//
// // worst situation.. we need to check for the right one
// for(CkanDataset dataset: datasets)
// for(CkanPair extra : dataset.getExtras())
// if(extra.getKey().contains(Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY) && extra.getValue().equals(suggestedRecordSemanticIdentifier)){
// logger.info("Matching dataset has id " + dataset.getId() + " with value " + Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY);
// return dataset;
// }
//
// }
//
// // in the end ....
// throw new Exception("Unable to find record with " + Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY + " equals to " + suggestedRecordSemanticIdentifier);
//
// }
/** /**
* Exploits the fact that in GRSF the url of a record contains the name (which is unique) of the record itself * Exploits the fact that in GRSF the url of a record contains the name (which is unique) of the record itself
* @param url * @param url
@ -527,20 +430,25 @@ public class Utils {
* @return {@link SimilarGRSFRecord} * @return {@link SimilarGRSFRecord}
* @throws ParseException * @throws ParseException
*/ */
public static SimilarGRSFRecord similarGRSFRecordFromJson(String json) throws ParseException{ public static SimilarGRSFRecord similarGRSFRecordFromJson(String json, DataCatalogue ctl, String apiKey) throws ParseException{
if(json == null) if(json == null)
return null; return null;
JSONParser parser = new JSONParser(); JSONParser parser = new JSONParser();
JSONObject object = (JSONObject)parser.parse(json); JSONObject object = (JSONObject)parser.parse(json);
String uuid = getDatasetKnowledgeBaseIdFromUrl((String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_URL));
CkanDataset dataset = ctl.getDataset(uuid, apiKey);
return new SimilarGRSFRecord( return new SimilarGRSFRecord(
uuid,
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_DESCRIPTION), (String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_DESCRIPTION),
getDatasetKnowledgeBaseIdFromUrl((String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_URL)),
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_IDENTIFIER),
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_NAME), (String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_NAME),
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_URL) dataset.getTitle(), // no title
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_URL),
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_IDENTIFIER),
dataset.getExtrasAsHashMap().get(Constants.DOMAIN_CUSTOM_KEY)
); );
} }
@ -589,19 +497,23 @@ public class Utils {
Map<String, List<String>> extrasWithoutNamespaces = Utils.replaceFieldsKey(destDataset.getExtras(), fieldsNamespacesMap); Map<String, List<String>> extrasWithoutNamespaces = Utils.replaceFieldsKey(destDataset.getExtras(), fieldsNamespacesMap);
String semanticId = extrasWithoutNamespaces.get(Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY).get(0); String semanticId = extrasWithoutNamespaces.get(Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY).get(0);
String destDomain = extrasWithoutNamespaces.get(Constants.DOMAIN_CUSTOM_KEY).get(0); String destDomain = extrasWithoutNamespaces.get(Constants.DOMAIN_CUSTOM_KEY).get(0);
String shortName = extrasWithoutNamespaces.get(Constants.SHORT_NAME_CUSTOM_KEY).get(0);
String description = destDataset.getNotes();
return new ConnectedBean( return new ConnectedBean(
connectedBeanUuid, connectedBeanUuid,
description,
shortName,
destDataset.getTitle(), destDataset.getTitle(),
destUrl, destUrl,
destDomain, semanticId,
semanticId destDomain
); );
} }
/** /**
* Fetch the sysadmin key from the IS * Fetch the sysadmin key from the IS for this catalogue
* @return * @return
* @throws Exception * @throws Exception
*/ */

View File

@ -1,20 +1,12 @@
package org.gcube.datacatalogue.grsf_manage_widget.shared; package org.gcube.datacatalogue.grsf_manage_widget.shared;
import java.io.Serializable;
/** /**
* Connect the current record with another record * Connect the current record with another record
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class ConnectedBean implements Serializable{ public class ConnectedBean extends GenericRecord{
private static final long serialVersionUID = -4863776727351488790L; private static final long serialVersionUID = -4863776727351488790L;
private String destKnowledgeBaseId; // the dest identifier of a Fishery or Stock (the link is from a Stock to a Fishery and vice versa)
private String destName;
private String destUrl;
private String destSemanticIdentifier;
private String destDomain; // please note that this MUST be different from sourceDomain
private boolean remove; private boolean remove;
private boolean connect; private boolean connect;
@ -22,28 +14,11 @@ public class ConnectedBean implements Serializable{
super(); super();
} }
/** public ConnectedBean(String knowledgeBaseId, String description,
* @param sourceKnowledgeBaseId String shortName, String title, String url,
* @param sourceDomain String semanticIdentifier, String domain) {
* @param sourceUrl super(knowledgeBaseId, description, shortName, title, url, semanticIdentifier,
* @param destKnowledgeBaseId domain);
* @param destTitle
* @param destUrl
* @param remove
* @param connect
*/
public ConnectedBean(
String destKnowledgeBaseId,
String destName,
String destUrl,
String destDomain,
String destSemanticIdentifier) {
super();
this.destKnowledgeBaseId = destKnowledgeBaseId;
this.destName = destName;
this.destUrl = destUrl;
this.destDomain = destDomain;
this.destSemanticIdentifier = destSemanticIdentifier;
} }
public boolean isConnect() { public boolean isConnect() {
@ -54,14 +29,6 @@ public class ConnectedBean implements Serializable{
this.connect = connect; this.connect = connect;
} }
public String getDestKnowledgeBaseId() {
return destKnowledgeBaseId;
}
public void setDestKnowledgeBaseId(String destKnowledgeBaseId) {
this.destKnowledgeBaseId = destKnowledgeBaseId;
}
public boolean isRemove() { public boolean isRemove() {
return remove; return remove;
} }
@ -70,45 +37,9 @@ public class ConnectedBean implements Serializable{
this.remove = remove; this.remove = remove;
} }
public String getDestName() {
return destName;
}
public void setDestName(String destName) {
this.destName = destName;
}
public String getDestUrl() {
return destUrl;
}
public void setDestUrl(String destUrl) {
this.destUrl = destUrl;
}
public String getDestDomain() {
return destDomain;
}
public void setDestDomain(String destDomain) {
this.destDomain = destDomain;
}
public String getDestSemanticIdentifier() {
return destSemanticIdentifier;
}
public void setDestSemanticIdentifier(String destSemanticIdentifier) {
this.destSemanticIdentifier = destSemanticIdentifier;
}
@Override @Override
public String toString() { public String toString() {
return "ConnectedBean [destKnowledgeBaseId=" + destKnowledgeBaseId return "ConnectedBean [record=" + super.toString() + ", remove=" + remove + ", connect=" + connect + "]";
+ ", destName=" + destName + ", destUrl=" + destUrl
+ ", destSemanticIdentifier=" + destSemanticIdentifier
+ ", destDomain=" + destDomain + ", remove=" + remove
+ ", connect=" + connect + "]";
} }
} }

View File

@ -0,0 +1,102 @@
package org.gcube.datacatalogue.grsf_manage_widget.shared;
import java.io.Serializable;
/**
* A generic record object.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class GenericRecord implements Serializable{
private static final long serialVersionUID = -7103588381218132232L;
private String knowledgeBaseId;
private String description;
private String shortName;
private String title;
private String url;
private String semanticIdentifier;
private String domain;
public GenericRecord() {
super();
}
public GenericRecord(String knowledgeBaseId, String description,
String shortName, String title, String url,
String semanticIdentifier, String domain) {
super();
this.knowledgeBaseId = knowledgeBaseId;
this.description = description;
this.shortName = shortName;
this.title = title;
this.url = url;
this.semanticIdentifier = semanticIdentifier;
this.domain = domain;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getKnowledgeBaseId() {
return knowledgeBaseId;
}
public void setKnowledgeBaseId(String knowledgeBaseId) {
this.knowledgeBaseId = knowledgeBaseId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getShortName() {
return shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getSemanticIdentifier() {
return semanticIdentifier;
}
public void setSemanticIdentifier(String semanticIdentifier) {
this.semanticIdentifier = semanticIdentifier;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
@Override
public String toString() {
return "GenericRecord [knowledgeBaseId=" + knowledgeBaseId
+ ", description=" + description + ", shortName=" + shortName
+ ", title=" + title + ", url=" + url + ", semanticIdentifier="
+ semanticIdentifier + ", domain=" + domain + "]";
}
}

View File

@ -3,12 +3,11 @@ package org.gcube.datacatalogue.grsf_manage_widget.shared;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import org.gcube.datacatalogue.common.enums.Status; import org.gcube.datacatalogue.common.enums.Status;
/** /**
* The bean to be managed by some people (e.g., GRSF). * The bean to be managed by GRSF Editors and Reviewers.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class ManageProductBean implements Serializable{ public class ManageProductBean implements Serializable{
@ -26,15 +25,15 @@ public class ManageProductBean implements Serializable{
private Status currentStatus; private Status currentStatus;
private Status newStatus; private Status newStatus;
private String annotation; // added by the administrator private String annotation; // added by the administrator
private Map<String, String> extrasIfAvailable; // read from GRSFManageEntries resource
private List<SourceRecord> sources; // sources for this record private List<SourceRecord> sources; // sources for this record
private List<SimilarGRSFRecord> similarGrsfRecords; private List<SimilarGRSFRecord> similarGrsfRecords;
private List<ConnectedBean> suggestedByKnowledgeBase; private List<ConnectedBean> suggestedByKnowledgeBaseConnections;
private List<ConnectedBean> suggestdByAdministrator = new ArrayList<ConnectedBean>(0); private List<ConnectedBean> suggestdByAdministratorConnections = new ArrayList<ConnectedBean>(0);
private List<ConnectedBean> currentConnections; private List<ConnectedBean> currentConnections;
private List<ConnectedBean> connections; // the one to used eventually private List<ConnectedBean> connections; // the one to used eventually
private boolean mergesInvolved; // important: in this case an email must be sent to the editors/reviewers private boolean mergesInvolved; // important: in this case an email must be sent to the editors/reviewers
private String recordUrl; // this record url private String recordUrl; // this record url
private String report; // the report that keeps track of the changes
public ManageProductBean() { public ManageProductBean() {
super(); super();
@ -50,12 +49,11 @@ public class ManageProductBean implements Serializable{
String shortName, String shortName,
boolean traceabilityFlag, boolean traceabilityFlag,
Status currentStatus, Status currentStatus,
String recordUrl, String recordUrl,
Map<String, String> extrasIfAvailable,
List<SourceRecord> sources, List<SourceRecord> sources,
List<SimilarGRSFRecord> similarGrsfRecords, List<SimilarGRSFRecord> similarGrsfRecords,
List<ConnectedBean> currentConnections, List<ConnectedBean> currentConnections,
List<ConnectedBean> suggestedByKnowledgeBase List<ConnectedBean> suggestedByKnowledgeBaseConnections
) { ) {
super(); super();
this.semanticIdentifier = semanticIdentifier; this.semanticIdentifier = semanticIdentifier;
@ -68,11 +66,10 @@ public class ManageProductBean implements Serializable{
this.shortNameUpdated = shortName; this.shortNameUpdated = shortName;
this.traceabilityFlag = traceabilityFlag; this.traceabilityFlag = traceabilityFlag;
this.currentStatus = currentStatus; this.currentStatus = currentStatus;
this.extrasIfAvailable = extrasIfAvailable;
this.sources = sources; this.sources = sources;
this.similarGrsfRecords = similarGrsfRecords; this.similarGrsfRecords = similarGrsfRecords;
this.currentConnections = currentConnections; this.currentConnections = currentConnections;
this.suggestedByKnowledgeBase = suggestedByKnowledgeBase; this.suggestedByKnowledgeBaseConnections = suggestedByKnowledgeBaseConnections;
this.recordUrl = recordUrl; this.recordUrl = recordUrl;
} }
@ -100,8 +97,6 @@ public class ManageProductBean implements Serializable{
this.similarGrsfRecords = similarGrsfRecords; this.similarGrsfRecords = similarGrsfRecords;
} }
public String getCatalogueIdentifier() { public String getCatalogueIdentifier() {
return catalogueIdentifier; return catalogueIdentifier;
} }
@ -142,14 +137,6 @@ public class ManageProductBean implements Serializable{
this.grsfName = grsfName; this.grsfName = grsfName;
} }
public Map<String, String> getExtrasIfAvailable() {
return extrasIfAvailable;
}
public void setExtrasIfAvailable(Map<String, String> extrasIfAvailable) {
this.extrasIfAvailable = extrasIfAvailable;
}
public Status getCurrentStatus() { public Status getCurrentStatus() {
return currentStatus; return currentStatus;
} }
@ -198,22 +185,22 @@ public class ManageProductBean implements Serializable{
this.shortNameUpdated = shortNameUpdated; this.shortNameUpdated = shortNameUpdated;
} }
public List<ConnectedBean> getSuggestedByKnowledgeBase() { public List<ConnectedBean> getSuggestedByKnowledgeBaseConnections() {
return suggestedByKnowledgeBase; return suggestedByKnowledgeBaseConnections;
} }
public void setSuggestedByKnowledgeBase( public void setSuggestedByKnowledgeBaseConnections(
List<ConnectedBean> suggestedByKnowledgeBase) { List<ConnectedBean> suggestedByKnowledgeBaseConnections) {
this.suggestedByKnowledgeBase = suggestedByKnowledgeBase; this.suggestedByKnowledgeBaseConnections = suggestedByKnowledgeBaseConnections;
} }
public List<ConnectedBean> getSuggestdByAdministrator() { public List<ConnectedBean> getSuggestdByAdministratorConnections() {
return suggestdByAdministrator; return suggestdByAdministratorConnections;
} }
public void setSuggestdByAdministrator( public void setSuggestdByAdministratorConnections(
List<ConnectedBean> suggestdByAdministrator) { List<ConnectedBean> suggestdByAdministratorConnections) {
this.suggestdByAdministrator = suggestdByAdministrator; this.suggestdByAdministratorConnections = suggestdByAdministratorConnections;
} }
public List<ConnectedBean> getCurrentConnections() { public List<ConnectedBean> getCurrentConnections() {
@ -248,6 +235,14 @@ public class ManageProductBean implements Serializable{
this.connections = connections; this.connections = connections;
} }
public String getReport() {
return report;
}
public void setReport(String report) {
this.report = report;
}
@Override @Override
public String toString() { public String toString() {
return "ManageProductBean [semanticIdentifier=" + semanticIdentifier return "ManageProductBean [semanticIdentifier=" + semanticIdentifier
@ -258,14 +253,13 @@ public class ManageProductBean implements Serializable{
+ ", shortNameUpdated=" + shortNameUpdated + ", shortNameUpdated=" + shortNameUpdated
+ ", traceabilityFlag=" + traceabilityFlag + ", currentStatus=" + ", traceabilityFlag=" + traceabilityFlag + ", currentStatus="
+ currentStatus + ", newStatus=" + newStatus + ", annotation=" + currentStatus + ", newStatus=" + newStatus + ", annotation="
+ annotation + ", extrasIfAvailable=" + extrasIfAvailable + annotation + ", sources=" + sources + ", similarGrsfRecords="
+ ", sources=" + sources + ", similarGrsfRecords=" + similarGrsfRecords + ", suggestedByKnowledgeBaseConnections="
+ similarGrsfRecords + ", suggestedByKnowledgeBase=" + suggestedByKnowledgeBaseConnections + ", suggestdByAdministratorConnections="
+ suggestedByKnowledgeBase + ", suggestdByAdministrator=" + suggestdByAdministratorConnections + ", currentConnections="
+ suggestdByAdministrator + ", currentConnections="
+ currentConnections + ", connections=" + connections + currentConnections + ", connections=" + connections
+ ", mergesInvolved=" + mergesInvolved + ", recordUrl=" + ", mergesInvolved=" + mergesInvolved + ", recordUrl="
+ recordUrl + "]"; + recordUrl + ", report=" + report + "]";
} }
} }

View File

@ -1,92 +1,23 @@
package org.gcube.datacatalogue.grsf_manage_widget.shared; package org.gcube.datacatalogue.grsf_manage_widget.shared;
import java.io.Serializable;
/** /**
* A similar grsf record. * A similar grsf record.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class SimilarGRSFRecord implements Serializable{ public class SimilarGRSFRecord extends GenericRecord{
private static final long serialVersionUID = 6501670015333073045L; private static final long serialVersionUID = 6501670015333073045L;
private String description;
private String knowledgeBaseId;
private String semanticIdentifier;
private String shortName;
private String url;
private boolean suggestedMerge; private boolean suggestedMerge;
public SimilarGRSFRecord() { public SimilarGRSFRecord() {
super(); super();
} }
/** public SimilarGRSFRecord(String knowledgeBaseId, String description,
* @param description String shortName, String title, String url,
* @param knowledgeBaseId String semanticIdentifier, String domain) {
* @param semanticIdentifier super(knowledgeBaseId, description, shortName, title, url, semanticIdentifier,
* @param shortName domain);
* @param url
* @param suggestedMerge
* @param isExtra
* @param toBeKept
*/
public SimilarGRSFRecord(String description, String knowledgeBaseId,
String semanticIdentifier, String shortName, String url) {
super();
this.description = description;
this.knowledgeBaseId = knowledgeBaseId;
this.semanticIdentifier = semanticIdentifier;
this.shortName = shortName;
this.url = url;
}
public String getKnowledgeBaseId() {
return knowledgeBaseId;
}
public void setKnowledgeBaseId(String knowledgeBaseId) {
this.knowledgeBaseId = knowledgeBaseId;
}
public String getSemanticIdentifier() {
return semanticIdentifier;
}
public void setSemanticIdentifier(String semanticIdentifier) {
this.semanticIdentifier = semanticIdentifier;
}
// public void setToBeKept(boolean toBeKept) {
// this.toBeKept = toBeKept;
// }
//
// public boolean isToBeKept() {
// return toBeKept;
// }
public String getShortName() {
return shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
} }
public boolean isSuggestedMerge() { public boolean isSuggestedMerge() {
@ -99,11 +30,6 @@ public class SimilarGRSFRecord implements Serializable{
@Override @Override
public String toString() { public String toString() {
return "SimilarGRSFRecord [description=" + description return "SimilarGRSFRecord [record=" + super.toString() + ", suggestedMerge=" + suggestedMerge + "]";
+ ", knowledgeBaseId=" + knowledgeBaseId
+ ", semanticIdentifier=" + semanticIdentifier + ", shortName="
+ shortName + ", url=" + url + ", suggestedMerge="
+ suggestedMerge + "]";
} }
} }

View File

@ -1,18 +1,14 @@
package org.gcube.datacatalogue.grsf_manage_widget.shared; package org.gcube.datacatalogue.grsf_manage_widget.shared;
import java.io.Serializable;
/** /**
* A source record for this grsf record: source type (i.e. fishsource, ram, firms), name and identifier * A source record for this grsf record: source type (i.e. fishsource, ram, firms), name and identifier
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class SourceRecord implements Serializable{ public class SourceRecord extends GenericRecord{
private static final long serialVersionUID = -5144710283443577518L; private static final long serialVersionUID = -5144710283443577518L;
private String name; private String name;
private String url; // within the catalogue
public SourceRecord() { public SourceRecord() {
super(); super();
} }
@ -24,7 +20,7 @@ public class SourceRecord implements Serializable{
public SourceRecord(String name, String url) { public SourceRecord(String name, String url) {
super(); super();
this.name = name; this.name = name;
this.url = url; setUrl(url);
} }
public String getName() { public String getName() {
@ -35,16 +31,9 @@ public class SourceRecord implements Serializable{
this.name = name; this.name = name;
} }
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override @Override
public String toString() { public String toString() {
return "SourceRecord [name=" + name + ", url=" + url + "]"; return "SourceRecord [name=" + name + "]";
} }
} }