diff --git a/.classpath b/.classpath
index eeb63b8..6d6f9dd 100644
--- a/.classpath
+++ b/.classpath
@@ -12,7 +12,7 @@
-
+
@@ -23,14 +23,14 @@
-
+
-
+
diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs
index 9a193e3..1a6de39 100644
--- a/.settings/com.google.gdt.eclipse.core.prefs
+++ b/.settings/com.google.gdt.eclipse.core.prefs
@@ -1,3 +1,4 @@
eclipse.preferences.version=1
+lastWarOutDir=/Users/costantinoperciante/Documents/workspace/grsf-manage-widget/target
warSrcDir=src/main/webapp
warSrcDirIsOutput=false
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 38e18cb..9f49a51 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -4,6 +4,10 @@
+
+
+ uses
+
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
index 735eb31..3f2dd2b 100644
--- a/.settings/org.eclipse.wst.common.project.facet.core.xml
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/pom.xml b/pom.xml
index 58d5b44..59b8415 100644
--- a/pom.xml
+++ b/pom.xml
@@ -243,5 +243,4 @@
- war
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetService.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetService.java
index 0af127b..9b93aa8 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetService.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetService.java
@@ -1,7 +1,5 @@
package org.gcube.datacatalogue.grsf_manage_widget.client;
-import java.util.List;
-
import org.gcube.datacatalogue.grsf_manage_widget.shared.ManageProductBean;
import com.google.gwt.user.client.rpc.RemoteService;
@@ -27,23 +25,7 @@ public interface GRSFManageWidgetService extends RemoteService {
/**
* Notify product update
*/
- String notifyProductUpdate(ManageProductBean bean, List hashtags) 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;
+ String notifyProductUpdate(ManageProductBean bean) throws Exception;
/**
* Identifier of the record (UUID)
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetServiceAsync.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetServiceAsync.java
index 871dce4..481cffd 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetServiceAsync.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetServiceAsync.java
@@ -3,8 +3,6 @@
*/
package org.gcube.datacatalogue.grsf_manage_widget.client;
-import java.util.List;
-
import org.gcube.datacatalogue.grsf_manage_widget.shared.ManageProductBean;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -15,7 +13,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
*/
public interface GRSFManageWidgetServiceAsync {
- void notifyProductUpdate(ManageProductBean bean, List hashtags,
+ void notifyProductUpdate(ManageProductBean bean,
AsyncCallback callback);
void getProductBeanById(String identifier,
@@ -23,12 +21,6 @@ public interface GRSFManageWidgetServiceAsync {
void isAdminUser(AsyncCallback callback);
- // void checkSemanticIdentifierExists(String semanticIdentifier,
- // AsyncCallback callback);
- //
- // void checkSemanticIdentifierExistsInDomain(String semanticIdentifier,
- // String domain, AsyncCallback callback);
-
void checkIdentifierExists(String id,
AsyncCallback callback);
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.java
index 4666335..5bab448 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.java
@@ -2,17 +2,13 @@ package org.gcube.datacatalogue.grsf_manage_widget.client.view;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import org.gcube.datacatalogue.common.enums.Status;
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.events.HideManagementPanelEvent;
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.SourceWidget;
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.TextBox;
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.dom.client.SelectElement;
import com.google.gwt.dom.client.Style.Unit;
@@ -91,6 +86,9 @@ public class ManageProductWidget extends Composite{
@UiField
VerticalPanel panelForSourceItems;
+ @UiField
+ ControlGroup similarGRSFRecordGroup;
+
@UiField
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";
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_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
private HandlerManager eventBus = null;
@@ -217,7 +214,6 @@ public class ManageProductWidget extends Composite{
@Override
public void onSuccess(ManageProductBean resBean) {
-
if(resBean == null){
showInfo(ERROR_ON_RETRIEVING_BEAN, AlertType.ERROR);
formUpdate.setVisible(false);
@@ -241,9 +237,12 @@ public class ManageProductWidget extends Composite{
panelForSourceItems.add(new SourceWidget(availableSources));
// manage similar GRSF records, if any
- List availableGRSFSimilarRecords = bean.getSimilarGrsfRecords();
- similarRecordPanel = new SimilarGRSFRecordWidget(availableGRSFSimilarRecords/*, service*/);
- panelForSimilarGRSFRecords.add(similarRecordPanel);
+ if(bean.getSimilarGrsfRecords() != null && !bean.getSimilarGrsfRecords().isEmpty()){
+ List availableGRSFSimilarRecords = bean.getSimilarGrsfRecords();
+ similarRecordPanel = new SimilarGRSFRecordWidget(availableGRSFSimilarRecords);
+ panelForSimilarGRSFRecords.add(similarRecordPanel);
+ }else
+ similarGRSFRecordGroup.setVisible(false);
// further suggested merges
suggestedMergesPanel = new SuggestMerges(service);
@@ -253,19 +252,16 @@ public class ManageProductWidget extends Composite{
connectWidget = new ConnectToWidget(bean, service);
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
List statusToShow = new ArrayList(STATUS);
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(!bean.getCurrentStatus().equals(Status.Approved))
statusToShow.remove(Status.Archived);
- listBoxStatus.addItem("Select the new status");
+ listBoxStatus.addItem("Select a new status");
listBoxStatus.getElement().cast().getOptions().getItem(0).setDisabled(true);
for (Status availableStatus : statusToShow) {
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 extras = bean.getExtrasIfAvailable();
- Iterator> iterator = extras.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry) iterator
- .next();
-
- formUpdate.insert(new FormEntryModel(entry.getKey(), entry.getValue()), index);
- index++;
-
- }
-
- }
-
@UiHandler("confirmButton")
void onSaveButton(ClickEvent ce){
- listBoxStatusGroup.setType(ControlGroupType.NONE);
-
- if(listBoxStatus.getSelectedIndex() <= 0){
- listBoxStatusGroup.setType(ControlGroupType.ERROR);
- return;
- }
-
+ // if the status has not be changed ...
+ if(listBoxStatus.getSelectedIndex() <= 0)
+ bean.setNewStatus(bean.getCurrentStatus());
+ else
+ bean.setNewStatus(Status.fromString(listBoxStatus.getSelectedItemText()));
+
manageProductModal.setCloseVisible(false);
cancelButton.setEnabled(false);
confirmButton.setEnabled(false);
@@ -354,19 +326,20 @@ public class ManageProductWidget extends Composite{
// evaluate the connections and the actions on them
bean.setConnections(connectWidget.getConnectList());
-
+
// update similar records and to connect
- bean.setSimilarGrsfRecords(similarRecordPanel.getSimilarRecords());
+ if(similarRecordPanel != null)
+ bean.setSimilarGrsfRecords(similarRecordPanel.getSimilarRecords());
+
bean.getSimilarGrsfRecords().addAll(suggestedMergesPanel.getSimilarRecords());
// set new values
bean.setAnnotation(new HTML(annotationArea.getText().trim()).getText());
- bean.setNewStatus(Status.fromString(listBoxStatus.getSelectedItemText()));
// traceability flag
bean.setTraceabilityFlag(traceabilityFlag.getValue());
- service.notifyProductUpdate(bean, null, new AsyncCallback() { // TODO add hashtags here
+ service.notifyProductUpdate(bean, new AsyncCallback() {
@Override
public void onSuccess(String result) {
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.ui.xml b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.ui.xml
index fab2dae..d1ac80c 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.ui.xml
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.ui.xml
@@ -8,7 +8,7 @@
}
-
@@ -83,7 +83,7 @@
- Source(s):
+ Source Record(s):
connectList = new ArrayList(0);
- private List currentlyConnected = null;
- private List suggestedByKnowledgeBase;
+ private List currentlyConnected; // they can be "unconnected" or "removed"
+ private List suggestedByKnowledgeBase; // they can be "connected"
+ private List suggestedByUser = new ArrayList(0); // they are "connected" if valid
private GRSFManageWidgetServiceAsync service;
public ConnectToWidget(final ManageProductBean bean, GRSFManageWidgetServiceAsync service) {
@@ -66,18 +68,6 @@ public class ConnectToWidget extends Composite{
this.service = service;
- // add the one suggested by the knowledge base
- suggestedByKnowledgeBase = bean.getSuggestedByKnowledgeBase();
-
- if(suggestedByKnowledgeBase != null){
- connectPanel.add(new HTML("
"));
- for (ConnectedBean connected : suggestedByKnowledgeBase) {
- Widget widget = buildWidgetForConnected(connected, true);
- connectPanel.add(widget);
- connectPanel.add(new HTML("
"));
- }
- }
-
// get already connected beans, and suggested ones
currentlyConnected = bean.getCurrentConnections();
@@ -90,25 +80,39 @@ public class ConnectToWidget extends Composite{
}
}
- // manage the button for manual suggestion
- String acceptedDomain = bean.getGrsfDomain().equalsIgnoreCase(Product_Type.STOCK.getOrigName()) ? Product_Type.FISHERY.getOrigName() : Product_Type.STOCK.getOrigName(); // inverted
- 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());
+ // add the one suggested by the knowledge base, they can be just "connected"
+ suggestedByKnowledgeBase = bean.getSuggestedByKnowledgeBaseConnections();
+ if(suggestedByKnowledgeBase != null){
+ for (ConnectedBean connected : suggestedByKnowledgeBase) {
+ Widget widget = buildWidgetForConnected(connected, true);
+ connectPanel.add(widget);
+ connectPanel.add(new HTML("
"));
}
- });
+ }
+
+ // 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();
leftPanel.setWidth("80%");
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);
Paragraph semanticIdentifier = new Paragraph("Semantic Identifier: " +
- connected.getDestSemanticIdentifier());
+ connected.getSemanticIdentifier());
leftPanel.add(semanticIdentifier);
Paragraph identifier = new Paragraph("Record UUID: " +
- connected.getDestKnowledgeBaseId());
+ connected.getKnowledgeBaseId());
leftPanel.add(identifier);
Anchor view = new Anchor();
- view.setHref(connected.getDestUrl());
+ view.setHref(connected.getUrl());
view.setText("View");
view.setTitle("Click to view the similar record");
view.setTarget("_blank");
@@ -145,10 +149,10 @@ public class ConnectToWidget extends Composite{
VerticalPanel rightPanel = new VerticalPanel();
rightPanel.setWidth("20%");
rightPanel.getElement().getStyle().setFloat(Float.RIGHT);
-
+
if(!suggestedByKb){
final CheckBox removeExtra = new CheckBox("Remove");
- removeExtra.setTitle("Remove this connections");
+ removeExtra.setTitle("Remove this connection");
removeExtra.addClickHandler(new ClickHandler() {
@Override
@@ -158,9 +162,9 @@ public class ConnectToWidget extends Composite{
});
rightPanel.add(removeExtra);
}
-
+
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.addClickHandler(new ClickHandler() {
@@ -170,7 +174,6 @@ public class ConnectToWidget extends Composite{
}
});
rightPanel.add(connect);
-
hp.add(leftPanel);
hp.add(rightPanel);
hp.getElement().getStyle().setPadding(10, Unit.PX);
@@ -182,8 +185,9 @@ public class ConnectToWidget extends Composite{
* Builds up a widget for connecting records.
* @param w the widget
* @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();
main.setWidth("100%");
@@ -193,7 +197,7 @@ public class ConnectToWidget extends Composite{
VerticalPanel vpLeft = new VerticalPanel();
vpLeft.getElement().getStyle().setMarginLeft(15, Unit.PX);
vpLeft.setWidth("80%");
- Paragraph semanticIdentifier = new Paragraph("Identifier (UUID):");
+ Paragraph semanticIdentifier = new Paragraph("UUID:");
final TextBox box = new TextBox();
final Icon icon = new Icon(IconType.OK_SIGN);
final Anchor view = new Anchor();
@@ -209,7 +213,7 @@ public class ConnectToWidget extends Composite{
public void onKeyPress(KeyPressEvent event) {
GWT.log("onKeyPress " + event.getNativeEvent().getKeyCode());
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() {
@@ -217,7 +221,7 @@ public class ConnectToWidget extends Composite{
@Override
public void onChange(ChangeEvent event) {
GWT.log("onChange");
- validateUUID(box, cb, icon, view);
+ validateUUID(box, cb, icon, view, acceptedDomain);
}
});
box.setWidth("512px");
@@ -230,8 +234,10 @@ public class ConnectToWidget extends Composite{
vpRight.setWidth("20%");
Button removeExtra = new Button();
- removeExtra.setIcon(IconType.MINUS);
- removeExtra.setTitle("Remove this connection");
+ removeExtra.setText("Remove");
+ removeExtra.setType(ButtonType.LINK);
+ removeExtra.getElement().getStyle().setFontWeight(FontWeight.BOLD);
+ removeExtra.setTitle("Remove this Connection");
removeExtra.addClickHandler(new ClickHandler() {
@Override
@@ -249,7 +255,6 @@ public class ConnectToWidget extends Composite{
}
}
});
- vpRight.getElement().getStyle().setFloat(Float.RIGHT);
vpRight.add(removeExtra);
hp.add(vpLeft);
hp.add(vpRight);
@@ -260,7 +265,7 @@ public class ConnectToWidget extends Composite{
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();
@@ -284,13 +289,13 @@ public class ConnectToWidget extends Composite{
icon.setIcon(IconType.ROTATE_RIGHT);
icon.setSpin(true);
- service.checkIdentifierExists(currentText, new AsyncCallback() {
+ service.checkIdentifierExistsInDomain(currentText, acceptedDomain, new AsyncCallback() {
@Override
public void onSuccess(String result) {
if(result != null){
- c.setDestKnowledgeBaseId(currentText);
+ c.setKnowledgeBaseId(currentText);
icon.setType(IconType.OK_CIRCLE);
icon.setSpin(false);
icon.setTitle("");
@@ -324,25 +329,26 @@ public class ConnectToWidget extends Composite{
* @return
*/
public List getConnectList() {
-
- TODO
-// List toReturn = new ArrayList<>();
-//
-// if(currentlyConnected != null)
-// currentlyConnected = new ArrayList(0);
-//
-// for (Tuple p : connectList) {
-// String suggestedIdentifier = ((ConnectedBean)p.getO()).getDestKnowledgeBaseId();
-// if(suggestedIdentifier == null || suggestedIdentifier.isEmpty())
-// continue;
-// else{
-// ConnectedBean connectedRecord = (ConnectedBean) p.getO();
-// connectedRecord.setToBeKept(true);
-// currentlyConnected.add((ConnectedBean) p.getO());
-// }
-// }
-//
-// return currentlyConnected;
+
+ //TODO
+ // List toReturn = new ArrayList<>();
+ //
+ // if(currentlyConnected != null)
+ // currentlyConnected = new ArrayList(0);
+ //
+ // for (Tuple p : connectList) {
+ // String suggestedIdentifier = ((ConnectedBean)p.getO()).getDestKnowledgeBaseId();
+ // if(suggestedIdentifier == null || suggestedIdentifier.isEmpty())
+ // continue;
+ // else{
+ // ConnectedBean connectedRecord = (ConnectedBean) p.getO();
+ // connectedRecord.setToBeKept(true);
+ // currentlyConnected.add((ConnectedBean) p.getO());
+ // }
+ // }
+ //
+ // return currentlyConnected;
+ return null;
}
}
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SimilarGRSFRecordWidget.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SimilarGRSFRecordWidget.java
index 3243c31..25487c7 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SimilarGRSFRecordWidget.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SimilarGRSFRecordWidget.java
@@ -25,11 +25,7 @@ import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
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
.create(SimilarGRSFRecordWidgetUiBinder.class);
@@ -40,25 +36,21 @@ public class SimilarGRSFRecordWidget extends Composite {
@UiField
VerticalPanel similarGrsfRecordsPanel;
- // @UiField
- // VerticalPanel similarGrsfRecordsSuggestedPanel;
- //
- // @UiField
- // Button addSimilarRecord;
@UiField
Button viewMore;
- // private List extraSimilarRecordsList = new ArrayList(0);
private List availableGRSFSimilarRecords;
private List toHide = new ArrayList();
- //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
* @param availableGRSFSimilarRecords
* @param service
*/
- public SimilarGRSFRecordWidget(List availableGRSFSimilarRecords/*, GRSFManageWidgetServiceAsync service*/) {
+ public SimilarGRSFRecordWidget(List availableGRSFSimilarRecords) {
initWidget(uiBinder.createAndBindUi(this));
//this.service = service;
@@ -133,7 +125,7 @@ public class SimilarGRSFRecordWidget extends Composite {
VerticalPanel leftPanel = new VerticalPanel();
leftPanel.setWidth("80%");
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);
if(similarGRSFRecord.getDescription() != null){
String shortDescrption = similarGRSFRecord.getDescription().length() > 45 ?
@@ -144,7 +136,7 @@ public class SimilarGRSFRecordWidget extends Composite {
description.setTitle("Description: " + similarGRSFRecord.getDescription());
leftPanel.add(description);
}
- Paragraph identifier = new Paragraph("Record UUID: " +
+ Paragraph identifier = new Paragraph("UUID: " +
similarGRSFRecord.getKnowledgeBaseId());
leftPanel.add(identifier);
@@ -162,33 +154,18 @@ public class SimilarGRSFRecordWidget extends Composite {
// add merge checkbox
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);
mergeSuggested.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
-
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.add(mergeSuggested);
- // rightPanel.add(removeExtra);
hp.add(leftPanel);
hp.add(rightPanel);
hp.getElement().getStyle().setPadding(10, Unit.PX);
@@ -202,16 +179,6 @@ public class SimilarGRSFRecordWidget extends Composite {
*/
public List getSimilarRecords(){
- if(availableGRSFSimilarRecords == null)
- availableGRSFSimilarRecords = new ArrayList();
-
- // for (Tuple p : extraSimilarRecordsList) {
- // SimilarGRSFRecord similarRecord = ((SimilarGRSFRecord)p.getO());
- // if(similarRecord.getKnowledgeBaseId() == null || similarRecord.getKnowledgeBaseId().isEmpty())
- // continue;
- // availableGRSFSimilarRecords.add((SimilarGRSFRecord) p.getO());
- // }
-
return availableGRSFSimilarRecords;
}
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SuggestMerges.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SuggestMerges.java
index 68ac813..4c64674 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SuggestMerges.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SuggestMerges.java
@@ -11,6 +11,7 @@ import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.Paragraph;
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.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Float;
@@ -56,31 +57,28 @@ public class SuggestMerges extends Composite {
public SuggestMerges(GRSFManageWidgetServiceAsync service) {
initWidget(uiBinder.createAndBindUi(this));
this.service = service;
+
// manage the "suggest button"
- addSimilarRecord.setIcon(IconType.PLUS_SIGN);
- addSimilarRecord.getElement().getStyle().setFloat(Float.RIGHT);
- addSimilarRecord.setTitle("Suggest a Similar Record by using its Identifier (UUID)");
+ addSimilarRecord.setText("Add Merge");
+ addSimilarRecord.getElement().getStyle().setFontWeight(FontWeight.BOLD);
+ addSimilarRecord.setType(ButtonType.LINK);
addSimilarRecord.getElement().getStyle().setFloat(Float.RIGHT);
+ addSimilarRecord.setTitle("Suggest a Similar Record to merge by using its Identifier (UUID)");
// add handler
addSimilarRecord.addClickHandler(new ClickHandler() {
-
@Override
public void onClick(ClickEvent arg0) {
-
SimilarGRSFRecord s = new SimilarGRSFRecord();
- // s.setExtra(true);
Widget w = buildWidgetForExtraSimilarRecord(s);
extraSimilarRecordsList.add(new Tuple(s, w, null));
similarGrsfRecordsSuggestedPanel.add(w);
-
}
});
}
/**
* 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 s the similar record.
*/
@@ -98,7 +96,7 @@ public class SuggestMerges extends Composite {
HorizontalPanel textBoxIconContainer = new HorizontalPanel();
textBoxIconContainer.setWidth("100%");
- Paragraph identifier = new Paragraph("Identifier (UUID):");
+ Paragraph identifier = new Paragraph("UUID:");
final TextBox box = new TextBox();
final Icon icon = new Icon(IconType.OK_SIGN);
final Anchor view = new Anchor();
@@ -114,7 +112,7 @@ public class SuggestMerges extends Composite {
public void onKeyPress(KeyPressEvent event) {
GWT.log("onKeyPress " + event.getNativeEvent().getKeyCode());
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() {
@@ -122,38 +120,26 @@ public class SuggestMerges extends Composite {
@Override
public void onChange(ChangeEvent event) {
GWT.log("onChange");
- validateUUID(box, s, icon, view);
+ validateUUID(box, s, icon, view, s.getDomain());
}
});
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);
textBoxIconContainer.add(box);
textBoxIconContainer.add(icon);
vpLeft.add(textBoxIconContainer);
vpLeft.add(view);
- // add merge checkbox
- // 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);
-
+ // the right side
VerticalPanel vpRight = new VerticalPanel();
vpRight.setWidth("20%");
- // mergeSuggested.addClickHandler(new ClickHandler() {
- //
- // @Override
- // public void onClick(ClickEvent arg0) {
- // s.setSuggestedMerge(mergeSuggested.getValue());
- // }
- // });
- //
- // vpRight.add(mergeSuggested);
Button removeExtra = new Button();
- removeExtra.setIcon(IconType.MINUS);
+ removeExtra.setText("Remove");
removeExtra.setTitle("Remove this suggested merge");
+ removeExtra.getElement().getStyle().setFontWeight(FontWeight.BOLD);
+ removeExtra.setType(ButtonType.LINK);
removeExtra.getElement().getStyle().setFloat(Float.RIGHT);
removeExtra.addClickHandler(new ClickHandler() {
@@ -174,7 +160,6 @@ public class SuggestMerges extends Composite {
});
vpRight.getElement().getStyle().setFloat(Float.RIGHT);
vpRight.add(removeExtra);
- // vpRight.add(mergeSuggested);
hp.add(vpLeft);
hp.add(vpRight);
HTML separator = new HTML("
");
@@ -184,7 +169,15 @@ public class SuggestMerges extends Composite {
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();
@@ -210,7 +203,7 @@ public class SuggestMerges extends Composite {
icon.setIcon(IconType.ROTATE_RIGHT);
icon.setSpin(true);
- service.checkIdentifierExists(currentText, new AsyncCallback() {
+ service.checkIdentifierExistsInDomain(currentText, domain, new AsyncCallback() {
@Override
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
*/
public List getSimilarRecords(){
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/Tuple.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/Tuple.java
index 0912873..3224332 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/Tuple.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/Tuple.java
@@ -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)
*/
public class Tuple {
@@ -16,10 +16,18 @@ public class Tuple {
this.w = w;
this.w2 = w2;
}
- public Object getO(){ return o; }
- public Widget getW(){ return w; }
- public void setO(Object o){ this.o = o; }
- public void setW(Widget w){ this.w = w; }
+ public Object
+ getO(){
+ return o; }
+ public Widget getW(){
+ return w;
+ }
+ public void setO(Object o){
+ this.o = o;
+ }
+ public void setW(Widget w){
+ this.w = w;
+ }
public Widget getW2() {
return w2;
}
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java
index a9b1caa..e1d9dd5 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java
@@ -28,10 +28,10 @@ import org.gcube.vomanagement.usermanagement.RoleManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
import org.gcube.vomanagement.usermanagement.model.GCubeTeam;
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.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.HttpClientBuilder;
@@ -46,8 +46,8 @@ import eu.trentorise.opendata.jackan.model.CkanResource;
public class GRSFNotificationService extends RemoteServiceServlet implements GRSFManageWidgetService{
private static final long serialVersionUID = -4534905087994875893L;
- //private static final Log logger = LogFactoryUtil.getLog(GRSFNotificationService.class);
- private static final Logger logger = LoggerFactory.getLogger(GRSFNotificationService.class);
+ private static final Log logger = LogFactoryUtil.getLog(GRSFNotificationService.class);
+ //private static final Logger logger = LoggerFactory.getLogger(GRSFNotificationService.class);
/**
* 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);
instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
}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;
}
return instance;
@@ -75,7 +75,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
ManageProductBean toReturn = null;
- // check into session first
+ // check into user's session first
HttpSession httpSession = getThreadLocalRequest().getSession();
String sessionProductKey = ScopeProvider.instance.get() + productIdentifier;
if(httpSession.getAttribute(sessionProductKey) != null)
@@ -86,15 +86,30 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
toReturn = new ManageProductBean();
toReturn.setCatalogueIdentifier(UUID.randomUUID().toString());
List connectTo = new ArrayList<>();
-
+ // these are the records alread connected
connectTo.add(new ConnectedBean(
- "89f1e413-dc9f-3b4e-b1c5-0e8560177254",
- "Random title",
- "http://data.d4science.org/ctlg/GRSF_Admin/89f1e413-dc9f-3b4e-b1c5-0e8560177254",
- "Fishery",
- "ajklsdkad:akljdnajdna"
+ "uuid-of-a-connected-bean",
+ "Random description",
+ "Random shortName",
+ "Random Title",
+ "http://data.d4science.org/ctlg/GRSF_Admin/uuid-of-a-connected-bean",
+ "semantic identifier of the record",
+ "Fishery"
));
toReturn.setCurrentConnections(connectTo);
+
+ // these are the "suggested connections"
+ List 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.setGrsfType("Assessment Unit");
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"));
toReturn.setSources(sources);
List similarGrsfRecords = new ArrayList();
- similarGrsfRecords.add(new SimilarGRSFRecord("same species overlapping water areas",
- Utils.getDatasetKnowledgeBaseIdFromUrl("http://data.d4science.org/ctlg/GRSF_Admin/1a03d6d8-002d-39b9-9255-a954c8ee2bf0")
- ,"unknown:ONCORHYNCHUS GORBUSCHA+unknown:USA-AKSTATE-KELPB",
- "Pink Salmon Kelp By (District112)",
- "http://data.d4science.org/ctlg/GRSF_Admin/1a03d6d8-002d-39b9-9255-a954c8ee2bf0"));
- similarGrsfRecords.add(new SimilarGRSFRecord("same species overlapping water areas 2",
- Utils.getDatasetKnowledgeBaseIdFromUrl("http://data.d4science.org/ctlg/GRSF_Admin/1a03d6d8-002d-39b9-9255-a954c8ee2bf0"),
- "unknown:ONCORHYNCHUS GORBUSCHA+unknown:USA-AKSTATE-KELPB",
- "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-1",
+ "description similar record",
+ "short name similar record 1",
+ "title similar record 1",
+ "http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-1",
+ "semantic identifier record 1",
+ "Stock 1"
+ ));
+ 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);
}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)
Map extrasAsMap = record.getExtrasAsHashMap();
- // get extras as hashmap and pairs
- List extrasAsPairs = record.getExtras();
-
String systemType = extrasAsMap.get(Constants.SYSTEM_TYPE_CUSTOM_KEY);
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());
@@ -154,22 +210,14 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
Utils.getFieldToFieldNameSpaceMapping(httpSession, isStock ?
Constants.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_STOCK : Constants.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_FISHERY);
+ // get extras as pairs
+ List extrasAsPairs = record.getExtras();
+
Map> 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();
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 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 shortName = extrasWithoutNamespaces.get(Constants.SHORT_NAME_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{
traceabilityFlag = extrasWithoutNamespaces.get(Constants.TRACEABILITY_FLAG_CUSTOM_KEY).get(0).equalsIgnoreCase("true");
}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))
List similarGrsfRecordsAsStrings = extrasWithoutNamespaces.containsKey(Constants.SIMILAR_GRSF_RECORDS_CUSTOM_KEY) ? extrasWithoutNamespaces.get(Constants.SIMILAR_GRSF_RECORDS_CUSTOM_KEY): null;
List similarRecords = new ArrayList(0);
- if(similarGrsfRecordsAsStrings != null){
- for (String similarGRSFRecord : similarGrsfRecordsAsStrings) {
- if(similarGRSFRecord.equals(Constants.NO_SIMILAR_GRSF_RECORDS)) // stop here if there is a single element with this information
- break;
- similarRecords.add(Utils.similarGRSFRecordFromJson(similarGRSFRecord));
+ if(similarGrsfRecordsAsStrings != null && !similarGrsfRecordsAsStrings.isEmpty()){
+ if(!similarGrsfRecordsAsStrings.get(0).equals(Constants.NO_SIMILAR_GRSF_RECORDS)){
+ for (String similarGRSFRecord : similarGrsfRecordsAsStrings) {
+ similarRecords.add(Utils.similarGRSFRecordFromJson(similarGRSFRecord, catalogue, apiKey));
+ }
}
}
@@ -201,13 +252,13 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
extrasWithoutNamespaces.containsKey(Constants.CONNECTED_CUSTOM_KEY) ? extrasWithoutNamespaces.get(Constants.CONNECTED_CUSTOM_KEY): null;
List connectedBeans = new ArrayList(0);
- if(connectedBeanUrls != null){
- for (String connectedBean : connectedBeanUrls) {
- if(connectedBean.equals(Constants.NO_CONNECTED_RECORDS)) // stop here if there is a single element with this information
- break;
- ConnectedBean builtBean = Utils.connectedBeanRecordFromUrl(connectedBean, catalogue, apiKey, httpSession);
- if(builtBean != null)
- connectedBeans.add(builtBean);
+ if(connectedBeanUrls != null && !connectedBeanUrls.isEmpty()){
+ if(!connectedBeanUrls.get(0).equals(Constants.NO_CONNECTED_RECORDS)){
+ for (String connectedBean : connectedBeanUrls) {
+ ConnectedBean builtBean = Utils.connectedBeanRecordFromUrl(connectedBean, catalogue, apiKey, httpSession);
+ if(builtBean != null)
+ connectedBeans.add(builtBean);
+ }
}
}
@@ -218,7 +269,8 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
List exploitedResourcesUrls = isStock ?
(extrasWithoutNamespaces.containsKey(Constants.EXPLOITING_FISHERY_JSON_KEY) ?
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()){
for (String exploited : exploitedResourcesUrls) {
@@ -239,15 +291,20 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
}
// set the values
- toReturn = new ManageProductBean(semanticId, catalogueIdentifier, uuidKB, grsfType,
- grsfDomain, grsfName, shortName, traceabilityFlag, status, recordUrl,
- null, sources, similarRecords, connectedBeans, suggestedConnectionsByKnowledgeBase);
+ toReturn = new ManageProductBean(
+ semanticId, catalogueIdentifier, uuidKB, grsfType,
+ grsfDomain, grsfName, shortName, traceabilityFlag,
+ status, recordUrl, sources, similarRecords,
+ connectedBeans, suggestedConnectionsByKnowledgeBase);
}
}
- logger.info("Returning item bean " + toReturn);
- httpSession.setAttribute(sessionProductKey, toReturn);
+ // save it into session
+ if(toReturn != null)
+ httpSession.setAttribute(sessionProductKey, toReturn);
+
+ logger.debug("Returning item bean " + toReturn);
return toReturn;
}
@@ -268,8 +325,8 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
String username = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
long userId = pContext.getCurrentUser(getThreadLocalRequest()).getUserId();
long groupId = pContext.getCurrentGroupId(getThreadLocalRequest());
- List teamRoles = roleManager.listTeamsByUserAndGroup(userId, groupId);
- toSetInSession = isEditor(username, teamRoles) | isReviewer(username, teamRoles);
+ List teamRolesByUser = roleManager.listTeamsByUserAndGroup(userId, groupId);
+ toSetInSession = isEditor(username, teamRolesByUser) | isReviewer(username, teamRolesByUser);
}
getThreadLocalRequest().getSession().setAttribute(Constants.GRSF_ADMIN_SESSION_KEY, toSetInSession);
return toSetInSession;
@@ -281,7 +338,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
}
@Override
- public String notifyProductUpdate(ManageProductBean bean, List hashtags) throws Exception{
+ public String notifyProductUpdate(ManageProductBean bean) throws Exception{
logger.info("Creating notification for the bean " + bean + " to send to the knowledge base");
try{
@@ -291,6 +348,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
DataCatalogue catalogue = getCatalogue(context);
String administratorFullName = Utils.getCurrentUser(getThreadLocalRequest()).getFullname();
String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername();
+
// check if the base url of the service is in session
String keyPerContext = UtilMethods.concatenateSessionKeyScope(Constants.GRSF_UPDATER_SERVICE, context);
HttpServletRequest threadRequest = getThreadLocalRequest();
@@ -305,7 +363,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
threadRequest.getSession().removeAttribute(sessionProductKey);
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){
logger.error("Unable to update the product", e);
@@ -324,10 +382,10 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
String fullName = user.getFullname();
long userId = pContext.getCurrentUser(getThreadLocalRequest()).getUserId();
long groupId = pContext.getCurrentGroupId(getThreadLocalRequest());
- List teamRoles = roleManager.listTeamsByUserAndGroup(userId, groupId);
+ List teamRolesByUser = roleManager.listTeamsByUserAndGroup(userId, groupId);
- boolean isEditor = isEditor(username, teamRoles);
- boolean isReviewer = isReviewer(username, teamRoles);
+ boolean isEditor = isEditor(username, teamRolesByUser);
+ boolean isReviewer = isReviewer(username, teamRolesByUser);
if(!(isEditor | isReviewer))
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 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)
boolean isValidTimestamp = decryptedUrl.isTimestampValid();
@@ -379,9 +437,9 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
* @param teamRoles
* @return true if he/she is an editor, false otherwise
*/
- private boolean isEditor(String username, List teamRoles){
+ private boolean isEditor(String username, List teamRolesByUser){
- for (GCubeTeam team : teamRoles) {
+ for (GCubeTeam team : teamRolesByUser) {
if(team.getTeamName().equals(Constants.GRSF_CATALOGUE_EDITOR_ROLE)){
logger.info("User " + username + " is allowed to modify GRSF records as editor");
return true;
@@ -396,9 +454,9 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
* @param teamRoles
* @return true if he/she is an reviewer, false otherwise
*/
- private boolean isReviewer(String username, List teamRoles){
+ private boolean isReviewer(String username, List teamRolesByUser){
- for (GCubeTeam team : teamRoles) {
+ for (GCubeTeam team : teamRolesByUser) {
if(team.getTeamName().equals(team.getTeamName().equals(Constants.GRSF_CATALOGUE_REVIEWER_ROLE))){
logger.info("User " + username + " is allowed to modify GRSF records as reviewer");
return true;
@@ -415,7 +473,11 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername();
CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username));
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);
}
@@ -426,9 +488,13 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl);
String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername();
CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username));
+
if(dataset == null)
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 extrasAsPairs = dataset.getExtras();
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 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;
- // }
-
}
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFUpdaterServiceClient.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFUpdaterServiceClient.java
index 45091f6..14e0048 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFUpdaterServiceClient.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFUpdaterServiceClient.java
@@ -123,7 +123,7 @@ public class GRSFUpdaterServiceClient {
JSONObject cc = new JSONObject();
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.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.CONNECTION_TO_REMOVE, c.isRemove());
}
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/SocialCommunications.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/SocialCommunications.java
index 2a8a60a..293d602 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/SocialCommunications.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/SocialCommunications.java
@@ -130,7 +130,7 @@ public class SocialCommunications {
* @param enablePostNotification
*/
@SuppressWarnings("unchecked")
- public static void writeProductPost(ManageProductBean bean, String username, String fullName, List 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
String currentScope = ScopeProvider.instance.get();
@@ -177,13 +177,14 @@ public class SocialCommunications {
// replace
String message = POST_MESSAGE.replace("PRODUCT_TITLE", bean.getGrsfName()).replace("PRODUCT_URL", bean.getRecordUrl()).replace("USER_FULLNAME", fullName);
- if(hashtags != null && !hashtags.isEmpty())
- for (String hashtag : hashtags) {
- String modifiedHashtag = hashtag.replaceAll(" ", "_").replace("_+", "_"); // no empty spaces allowed
- if(modifiedHashtag.endsWith("_"))
- modifiedHashtag = modifiedHashtag.substring(0, modifiedHashtag.length() - 1);
- message += " #" + modifiedHashtag;
- }
+ // evaluate hashtags from the report ... TODO
+ // if(hashtags != null && !hashtags.isEmpty())
+ // for (String hashtag : hashtags) {
+ // String modifiedHashtag = hashtag.replaceAll(" ", "_").replace("_+", "_"); // no empty spaces allowed
+ // if(modifiedHashtag.endsWith("_"))
+ // modifiedHashtag = modifiedHashtag.substring(0, modifiedHashtag.length() - 1);
+ // message += " #" + modifiedHashtag;
+ // }
logger.info("The post that is going to be written is -> " + message);
postRequest = new HttpPost(basePath + SOCIAL_SERVICE_WRITE_APPLICATION_POST + "?gcube-token=" + applicationToken);
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/Utils.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/Utils.java
index 07e604d..2f4c523 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/Utils.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/Utils.java
@@ -6,10 +6,8 @@ import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.regex.Matcher;
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.DataCatalogue;
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.enums.Product_Type;
import org.gcube.datacatalogue.common.enums.Status;
@@ -58,62 +55,9 @@ import eu.trentorise.opendata.jackan.model.CkanPair;
*/
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 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 getLookedUpExtrasKeys() {
- Set lookedUpExtrasKeys = new HashSet();
- 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 client = client();
- List 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 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.
* @param httpSession
@@ -243,7 +187,7 @@ public class Utils {
long groupId,
String context,
String token,
- List hashtags) throws Exception{
+ String report) throws Exception{
if(serviceUrl == null)
throw new IllegalArgumentException("GRSF Updater service url cannot be null");
@@ -260,7 +204,7 @@ public class Utils {
// send update to the knowledge base
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(()->{
ScopeProvider.instance.set(context);
@@ -271,10 +215,13 @@ public class Utils {
SocialCommunications.sendEmailAdministrators(bean, catalogue, username, fullName, groupId, httpServletRequest, bean.isMergesInvolved());
// create a post about the operation
- SocialCommunications.writeProductPost(bean, username, fullName, hashtags, true);
+ SocialCommunications.writeProductPost(bean, username, fullName, report, true);
}catch(Exception e){
logger.error("Something failed while alerting editors/reviewers", e);
+ }finally{
+ ScopeProvider.instance.reset();
+ SecurityTokenProvider.instance.reset();
}
}).start();
@@ -396,50 +343,6 @@ public class Utils {
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 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
* @param url
@@ -527,20 +430,25 @@ public class Utils {
* @return {@link SimilarGRSFRecord}
* @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)
return null;
JSONParser parser = new JSONParser();
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(
+ uuid,
(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_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> extrasWithoutNamespaces = Utils.replaceFieldsKey(destDataset.getExtras(), fieldsNamespacesMap);
String semanticId = extrasWithoutNamespaces.get(Constants.GRSF_SEMANTIC_IDENTIFIER_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(
connectedBeanUuid,
+ description,
+ shortName,
destDataset.getTitle(),
destUrl,
- destDomain,
- semanticId
+ semanticId,
+ destDomain
);
}
/**
- * Fetch the sysadmin key from the IS
+ * Fetch the sysadmin key from the IS for this catalogue
* @return
* @throws Exception
*/
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ConnectedBean.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ConnectedBean.java
index 626855e..380850b 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ConnectedBean.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ConnectedBean.java
@@ -1,20 +1,12 @@
package org.gcube.datacatalogue.grsf_manage_widget.shared;
-import java.io.Serializable;
-
-
/**
* Connect the current record with another record
* @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 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 connect;
@@ -22,28 +14,11 @@ public class ConnectedBean implements Serializable{
super();
}
- /**
- * @param sourceKnowledgeBaseId
- * @param sourceDomain
- * @param sourceUrl
- * @param destKnowledgeBaseId
- * @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 ConnectedBean(String knowledgeBaseId, String description,
+ String shortName, String title, String url,
+ String semanticIdentifier, String domain) {
+ super(knowledgeBaseId, description, shortName, title, url, semanticIdentifier,
+ domain);
}
public boolean isConnect() {
@@ -54,14 +29,6 @@ public class ConnectedBean implements Serializable{
this.connect = connect;
}
- public String getDestKnowledgeBaseId() {
- return destKnowledgeBaseId;
- }
-
- public void setDestKnowledgeBaseId(String destKnowledgeBaseId) {
- this.destKnowledgeBaseId = destKnowledgeBaseId;
- }
-
public boolean isRemove() {
return remove;
}
@@ -70,45 +37,9 @@ public class ConnectedBean implements Serializable{
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
public String toString() {
- return "ConnectedBean [destKnowledgeBaseId=" + destKnowledgeBaseId
- + ", destName=" + destName + ", destUrl=" + destUrl
- + ", destSemanticIdentifier=" + destSemanticIdentifier
- + ", destDomain=" + destDomain + ", remove=" + remove
- + ", connect=" + connect + "]";
+ return "ConnectedBean [record=" + super.toString() + ", remove=" + remove + ", connect=" + connect + "]";
}
}
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/GenericRecord.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/GenericRecord.java
new file mode 100644
index 0000000..5812215
--- /dev/null
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/GenericRecord.java
@@ -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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ManageProductBean.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ManageProductBean.java
index c30c02a..b2f1159 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ManageProductBean.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ManageProductBean.java
@@ -3,12 +3,11 @@ package org.gcube.datacatalogue.grsf_manage_widget.shared;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
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)
*/
public class ManageProductBean implements Serializable{
@@ -26,15 +25,15 @@ public class ManageProductBean implements Serializable{
private Status currentStatus;
private Status newStatus;
private String annotation; // added by the administrator
- private Map extrasIfAvailable; // read from GRSFManageEntries resource
private List sources; // sources for this record
private List similarGrsfRecords;
- private List suggestedByKnowledgeBase;
- private List suggestdByAdministrator = new ArrayList(0);
+ private List suggestedByKnowledgeBaseConnections;
+ private List suggestdByAdministratorConnections = new ArrayList(0);
private List currentConnections;
private List connections; // the one to used eventually
private boolean mergesInvolved; // important: in this case an email must be sent to the editors/reviewers
private String recordUrl; // this record url
+ private String report; // the report that keeps track of the changes
public ManageProductBean() {
super();
@@ -50,12 +49,11 @@ public class ManageProductBean implements Serializable{
String shortName,
boolean traceabilityFlag,
Status currentStatus,
- String recordUrl,
- Map extrasIfAvailable,
+ String recordUrl,
List sources,
List similarGrsfRecords,
List currentConnections,
- List suggestedByKnowledgeBase
+ List suggestedByKnowledgeBaseConnections
) {
super();
this.semanticIdentifier = semanticIdentifier;
@@ -68,11 +66,10 @@ public class ManageProductBean implements Serializable{
this.shortNameUpdated = shortName;
this.traceabilityFlag = traceabilityFlag;
this.currentStatus = currentStatus;
- this.extrasIfAvailable = extrasIfAvailable;
this.sources = sources;
this.similarGrsfRecords = similarGrsfRecords;
this.currentConnections = currentConnections;
- this.suggestedByKnowledgeBase = suggestedByKnowledgeBase;
+ this.suggestedByKnowledgeBaseConnections = suggestedByKnowledgeBaseConnections;
this.recordUrl = recordUrl;
}
@@ -100,8 +97,6 @@ public class ManageProductBean implements Serializable{
this.similarGrsfRecords = similarGrsfRecords;
}
-
-
public String getCatalogueIdentifier() {
return catalogueIdentifier;
}
@@ -142,14 +137,6 @@ public class ManageProductBean implements Serializable{
this.grsfName = grsfName;
}
- public Map getExtrasIfAvailable() {
- return extrasIfAvailable;
- }
-
- public void setExtrasIfAvailable(Map extrasIfAvailable) {
- this.extrasIfAvailable = extrasIfAvailable;
- }
-
public Status getCurrentStatus() {
return currentStatus;
}
@@ -198,22 +185,22 @@ public class ManageProductBean implements Serializable{
this.shortNameUpdated = shortNameUpdated;
}
- public List getSuggestedByKnowledgeBase() {
- return suggestedByKnowledgeBase;
+ public List getSuggestedByKnowledgeBaseConnections() {
+ return suggestedByKnowledgeBaseConnections;
}
- public void setSuggestedByKnowledgeBase(
- List suggestedByKnowledgeBase) {
- this.suggestedByKnowledgeBase = suggestedByKnowledgeBase;
+ public void setSuggestedByKnowledgeBaseConnections(
+ List suggestedByKnowledgeBaseConnections) {
+ this.suggestedByKnowledgeBaseConnections = suggestedByKnowledgeBaseConnections;
}
- public List getSuggestdByAdministrator() {
- return suggestdByAdministrator;
+ public List getSuggestdByAdministratorConnections() {
+ return suggestdByAdministratorConnections;
}
- public void setSuggestdByAdministrator(
- List suggestdByAdministrator) {
- this.suggestdByAdministrator = suggestdByAdministrator;
+ public void setSuggestdByAdministratorConnections(
+ List suggestdByAdministratorConnections) {
+ this.suggestdByAdministratorConnections = suggestdByAdministratorConnections;
}
public List getCurrentConnections() {
@@ -248,6 +235,14 @@ public class ManageProductBean implements Serializable{
this.connections = connections;
}
+ public String getReport() {
+ return report;
+ }
+
+ public void setReport(String report) {
+ this.report = report;
+ }
+
@Override
public String toString() {
return "ManageProductBean [semanticIdentifier=" + semanticIdentifier
@@ -258,14 +253,13 @@ public class ManageProductBean implements Serializable{
+ ", shortNameUpdated=" + shortNameUpdated
+ ", traceabilityFlag=" + traceabilityFlag + ", currentStatus="
+ currentStatus + ", newStatus=" + newStatus + ", annotation="
- + annotation + ", extrasIfAvailable=" + extrasIfAvailable
- + ", sources=" + sources + ", similarGrsfRecords="
- + similarGrsfRecords + ", suggestedByKnowledgeBase="
- + suggestedByKnowledgeBase + ", suggestdByAdministrator="
- + suggestdByAdministrator + ", currentConnections="
+ + annotation + ", sources=" + sources + ", similarGrsfRecords="
+ + similarGrsfRecords + ", suggestedByKnowledgeBaseConnections="
+ + suggestedByKnowledgeBaseConnections + ", suggestdByAdministratorConnections="
+ + suggestdByAdministratorConnections + ", currentConnections="
+ currentConnections + ", connections=" + connections
+ ", mergesInvolved=" + mergesInvolved + ", recordUrl="
- + recordUrl + "]";
+ + recordUrl + ", report=" + report + "]";
}
}
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/SimilarGRSFRecord.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/SimilarGRSFRecord.java
index ba522c8..1736597 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/SimilarGRSFRecord.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/SimilarGRSFRecord.java
@@ -1,92 +1,23 @@
package org.gcube.datacatalogue.grsf_manage_widget.shared;
-import java.io.Serializable;
-
-
/**
* A similar grsf record.
* @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 String description;
- private String knowledgeBaseId;
- private String semanticIdentifier;
- private String shortName;
- private String url;
private boolean suggestedMerge;
public SimilarGRSFRecord() {
super();
}
- /**
- * @param description
- * @param knowledgeBaseId
- * @param semanticIdentifier
- * @param shortName
- * @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 SimilarGRSFRecord(String knowledgeBaseId, String description,
+ String shortName, String title, String url,
+ String semanticIdentifier, String domain) {
+ super(knowledgeBaseId, description, shortName, title, url, semanticIdentifier,
+ domain);
}
public boolean isSuggestedMerge() {
@@ -99,11 +30,6 @@ public class SimilarGRSFRecord implements Serializable{
@Override
public String toString() {
- return "SimilarGRSFRecord [description=" + description
- + ", knowledgeBaseId=" + knowledgeBaseId
- + ", semanticIdentifier=" + semanticIdentifier + ", shortName="
- + shortName + ", url=" + url + ", suggestedMerge="
- + suggestedMerge + "]";
+ return "SimilarGRSFRecord [record=" + super.toString() + ", suggestedMerge=" + suggestedMerge + "]";
}
-
}
diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/SourceRecord.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/SourceRecord.java
index 3bc718a..e5d4c08 100644
--- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/SourceRecord.java
+++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/SourceRecord.java
@@ -1,18 +1,14 @@
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
* @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 String name;
- private String url; // within the catalogue
-
+
public SourceRecord() {
super();
}
@@ -24,7 +20,7 @@ public class SourceRecord implements Serializable{
public SourceRecord(String name, String url) {
super();
this.name = name;
- this.url = url;
+ setUrl(url);
}
public String getName() {
@@ -35,16 +31,9 @@ public class SourceRecord implements Serializable{
this.name = name;
}
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
@Override
public String toString() {
- return "SourceRecord [name=" + name + ", url=" + url + "]";
+ return "SourceRecord [name=" + name + "]";
}
+
}
\ No newline at end of file