Costantino Perciante 2017-11-23 19:04:47 +00:00
parent 9fbe4038e3
commit db0d9b057e
52 changed files with 381 additions and 123 deletions

View File

@ -112,18 +112,18 @@
<dependency> <dependency>
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId> <artifactId>common-scope-maps</artifactId>
<scope>provided</scope> <scope>compile</scope>
<!-- put at provided for deploying --> <!-- put at provided for deploying -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId> <artifactId>common-encryption</artifactId>
<scope>provided</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId> <artifactId>authorization-client</artifactId>
<scope>provided</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -234,4 +234,5 @@
</plugins> </plugins>
</build> </build>
<packaging>war</packaging>
</project> </project>

View File

@ -14,7 +14,6 @@ public interface GRSFManageWidgetService extends RemoteService {
*/ */
boolean isAdminUser(); boolean isAdminUser();
/** /**
* Get the product bean from the product identifier * Get the product bean from the product identifier
* @param identifier * @param identifier
@ -26,6 +25,22 @@ public interface GRSFManageWidgetService extends RemoteService {
/** /**
* Notify product update * Notify product update
*/ */
String notifyProductUpdate(ManageProductBean bean); 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;
} }

View File

@ -21,4 +21,10 @@ 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);
} }

View File

@ -142,7 +142,10 @@ public class ManageProductWidget extends Composite{
// the objects to be managed // the objects to be managed
private ManageProductBean bean; private ManageProductBean bean;
private final static List<Status> STATUS = new ArrayList<Status>(Arrays.asList(Status.values())); private final static List<Status> STATUS = new ArrayList<Status>(Arrays.asList(Status.values()));
// similar records and to connect widgets
private SimilarGRSFRecordWidget similarRecordPanel;
private ConnectToWidget connectWidget;
/** /**
* Build a ManageProduct widget for the product with the specified id. * Build a ManageProduct widget for the product with the specified id.
@ -184,8 +187,6 @@ public class ManageProductWidget extends Composite{
@Override @Override
public void onSuccess(Boolean result) { public void onSuccess(Boolean result) {
GWT.log("Get " + result);
if(!result){ if(!result){
showInfo(NO_ADMIN_ROLE, AlertType.ERROR); showInfo(NO_ADMIN_ROLE, AlertType.ERROR);
@ -205,7 +206,6 @@ public class ManageProductWidget extends Composite{
@Override @Override
public void onSuccess(ManageProductBean resBean) { public void onSuccess(ManageProductBean resBean) {
// GWT.log("Get " + resBean);
if(resBean == null){ if(resBean == null){
showInfo(ERROR_ON_RETRIEVING_BEAN, AlertType.ERROR); showInfo(ERROR_ON_RETRIEVING_BEAN, AlertType.ERROR);
@ -230,10 +230,12 @@ public class ManageProductWidget extends Composite{
// manage similar GRSF records, if any // manage similar GRSF records, if any
List<SimilarGRSFRecord> availableGRSFSimilarRecords = bean.getSimilarGrsfRecords(); List<SimilarGRSFRecord> availableGRSFSimilarRecords = bean.getSimilarGrsfRecords();
panelForSimilarGRSFRecords.add(new SimilarGRSFRecordWidget(availableGRSFSimilarRecords)); similarRecordPanel = new SimilarGRSFRecordWidget(availableGRSFSimilarRecords, service);
panelForSimilarGRSFRecords.add(similarRecordPanel);
// prepare "connect" panel // prepare "connect" panel
panelForConnectOtherRecords.add(new ConnectToWidget()); connectWidget = new ConnectToWidget(bean, service);
panelForConnectOtherRecords.add(connectWidget);
// check if we need to show more // check if we need to show more
if(bean.getExtrasIfAvailable() != null && !bean.getExtrasIfAvailable().isEmpty()) if(bean.getExtrasIfAvailable() != null && !bean.getExtrasIfAvailable().isEmpty())
@ -338,6 +340,10 @@ public class ManageProductWidget extends Composite{
cancelButton.setEnabled(false); cancelButton.setEnabled(false);
confirmButton.setEnabled(false); confirmButton.setEnabled(false);
loaderIcon.setVisible(true); loaderIcon.setVisible(true);
// update similar records and to connect
bean.setConnectTo(connectWidget.getConnectList());
bean.setSimilarGrsfRecords(similarRecordPanel.getSimilarRecords());
// set new values // set new values
bean.setAnnotation(new HTML(annotationArea.getText().trim()).getText()); bean.setAnnotation(new HTML(annotationArea.getText().trim()).getText());
@ -378,7 +384,6 @@ public class ManageProductWidget extends Composite{
@UiHandler("cancelButton") @UiHandler("cancelButton")
void onCancelButton(ClickEvent ce){ void onCancelButton(ClickEvent ce){
// just hide the panel
manageProductModal.hide(); manageProductModal.hide();
} }

View File

@ -106,7 +106,7 @@
<b>Suggest connections with other records:</b> <b>Suggest connections with other records:</b>
</b:ControlLabel> </b:ControlLabel>
<b:Controls> <b:Controls>
<g:VerticalPanel ui:field="panelForConnectOtherRecords"> <g:VerticalPanel ui:field="panelForConnectOtherRecords" width="100%">
</g:VerticalPanel> </g:VerticalPanel>
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>

View File

@ -1,8 +1,32 @@
package org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets; package org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetServiceAsync;
import org.gcube.datacatalogue.grsf_manage_widget.shared.ConnectBean;
import org.gcube.datacatalogue.grsf_manage_widget.shared.ManageProductBean;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.TextBox;
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.Unit;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
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 ConnectToWidget extends Composite{ public class ConnectToWidget extends Composite{
@ -13,9 +37,130 @@ public class ConnectToWidget extends Composite{
interface ConnectToWidgetUiBinder extends UiBinder<Widget, ConnectToWidget> { interface ConnectToWidgetUiBinder extends UiBinder<Widget, ConnectToWidget> {
} }
public ConnectToWidget() { @UiField
VerticalPanel connectPanel;
@UiField
Button suggestRecord;
private GRSFManageWidgetServiceAsync service;
private List<Pair> connectList = new ArrayList<Pair>(0);
public ConnectToWidget(final ManageProductBean bean, GRSFManageWidgetServiceAsync service) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.service = service;
String acceptedDomain = bean.getGrsfDomain().equalsIgnoreCase("stock") ? "Fishery" : "Stock";
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) {
ConnectBean cb = new ConnectBean();
cb.setSourceDomain(bean.getGrsfDomain());
Widget w = buildWidgetConnect(cb);
connectList.add(new Pair(cb, w));
connectPanel.add(w);
}
});
}
/**
* Builds up a widget for connecting records.
* @param w the widget
* @param cb the connectBean.
*/
private Widget buildWidgetConnect(final ConnectBean cb){
VerticalPanel main = new VerticalPanel();
main.setWidth("90%");
HorizontalPanel hp = new HorizontalPanel();
hp.setWidth("100%");
VerticalPanel vpLeft = new VerticalPanel();
vpLeft.getElement().getStyle().setMarginLeft(15, Unit.PX);
vpLeft.setWidth("80%");
Paragraph semanticIdentifier = new Paragraph("Semantic Identifier:");
final TextBox box = new TextBox();
box.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
String currentText = box.getText().trim();
GWT.log("Text changed to " + currentText);
cb.setDestSemanticIdentifier(currentText);
}
});
box.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
String currentText = box.getText().trim();
GWT.log("Text changed to " + currentText);
cb.setDestSemanticIdentifier(currentText);
}
});
box.setWidth("512px");
box.setPlaceholder("Insert the Semantic Identifier of the record to connect");
vpLeft.add(semanticIdentifier);
vpLeft.add(box);
VerticalPanel vpRight = new VerticalPanel();
vpRight.setWidth("20%");
Button removeExtra = new Button();
removeExtra.setIcon(IconType.MINUS);
removeExtra.setTitle("Remove this connection");
removeExtra.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
// remove this object from the pairs list
Iterator<Pair> iterator = connectList.iterator();
while (iterator.hasNext()) {
Pair pair = (Pair) iterator
.next();
if(pair.getO().equals(cb)){
pair.getW().removeFromParent();
iterator.remove();
}
}
}
});
vpRight.getElement().getStyle().setFloat(Float.RIGHT);
vpRight.add(removeExtra);
hp.add(vpLeft);
hp.add(vpRight);
HTML separator = new HTML("<hr style=\"width:100%;\"/>");
connectPanel.add(separator);
main.add(hp);
main.add(separator);
return main;
} }
public List<ConnectBean> getConnectList() {
List<ConnectBean> toReturn = new ArrayList<ConnectBean>(0);
for (Pair p : connectList) {
toReturn.add((ConnectBean) p.getO());
}
return toReturn;
}
} }

View File

@ -1,12 +1,9 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"> xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style> <g:HTMLPanel width="100%">
.important { <g:VerticalPanel ui:field="connectPanel" width="100%">
font-weight: bold; </g:VerticalPanel>
} <b:Button ui:field="suggestRecord"></b:Button>
</ui:style>
<g:HTMLPanel>
<g:VerticalPanel ui:field="connectPanel"></g:VerticalPanel>
</g:HTMLPanel> </g:HTMLPanel>
</ui:UiBinder> </ui:UiBinder>

View File

@ -0,0 +1,25 @@
package org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets;
import com.google.gwt.user.client.ui.Widget;
/**
* A class of pair: a widget and an object
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class Pair {
private Object o;
private Widget w;
public Pair(Object o, Widget w){
this.o = o;
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; }
@Override
public String toString() {
return "Pair [o=" + o + ", w=" + w + "]";
}
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetServiceAsync;
import org.gcube.datacatalogue.grsf_manage_widget.shared.SimilarGRSFRecord; import org.gcube.datacatalogue.grsf_manage_widget.shared.SimilarGRSFRecord;
import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Button;
@ -15,8 +16,12 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Float; import com.google.gwt.dom.client.Style.Float;
import com.google.gwt.dom.client.Style.FontWeight; import com.google.gwt.dom.client.Style.FontWeight;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Anchor;
@ -44,33 +49,19 @@ public class SimilarGRSFRecordWidget extends Composite {
@UiField @UiField
Button addSimilarRecord; Button addSimilarRecord;
/** private List<Pair> extraSimilarRecordsList = new ArrayList<Pair>(0);
* Class of Pairs
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
class Pair {
private SimilarGRSFRecord s;
private Widget w;
public Pair(SimilarGRSFRecord s, Widget w){
this.s = s;
this.w = w;
}
public SimilarGRSFRecord getS(){ return s; }
public Widget getW(){ return w; }
public void setS(SimilarGRSFRecord s){ this.s = s; }
public void setW(Widget w){ this.w = w; }
}
protected List<Pair> extraSimilarRecordsList = new ArrayList<Pair>(0);
private List<SimilarGRSFRecord> availableGRSFSimilarRecords; private List<SimilarGRSFRecord> availableGRSFSimilarRecords;
private GRSFManageWidgetServiceAsync service;
/** /**
* Get widget for available similar grsf records * Get widget for available similar grsf records
* @param availableGRSFSimilarRecords * @param availableGRSFSimilarRecords
* @param service
*/ */
public SimilarGRSFRecordWidget(List<SimilarGRSFRecord> availableGRSFSimilarRecords) { public SimilarGRSFRecordWidget(List<SimilarGRSFRecord> availableGRSFSimilarRecords, GRSFManageWidgetServiceAsync service) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.service = service;
this.availableGRSFSimilarRecords = availableGRSFSimilarRecords; this.availableGRSFSimilarRecords = availableGRSFSimilarRecords;
addSimilarRecord.getElement().getStyle().setFloat(Float.RIGHT); addSimilarRecord.getElement().getStyle().setFloat(Float.RIGHT);
@ -85,7 +76,7 @@ public class SimilarGRSFRecordWidget extends Composite {
// manage the "suggest button" // manage the "suggest button"
addSimilarRecord.setIcon(IconType.PLUS_SIGN); addSimilarRecord.setIcon(IconType.PLUS_SIGN);
addSimilarRecord.getElement().getStyle().setFloat(Float.RIGHT); addSimilarRecord.getElement().getStyle().setFloat(Float.RIGHT);
addSimilarRecord.setTitle("Suggest a Similar Record by using its GRSF UUID"); addSimilarRecord.setTitle("Suggest a Similar Record by using its GRSF Semantic Identifier");
// add handler // add handler
addSimilarRecord.addClickHandler(new ClickHandler() { addSimilarRecord.addClickHandler(new ClickHandler() {
@ -126,7 +117,7 @@ public class SimilarGRSFRecordWidget extends Composite {
description.setTitle("Description: " + similarGRSFRecord.getDescription()); description.setTitle("Description: " + similarGRSFRecord.getDescription());
leftPanel.add(description); leftPanel.add(description);
} }
Paragraph semanticIdentifier = new Paragraph("Semantic Identifier " + Paragraph semanticIdentifier = new Paragraph("Semantic Identifier: " +
similarGRSFRecord.getSemanticIdentifier()); similarGRSFRecord.getSemanticIdentifier());
leftPanel.add(semanticIdentifier); leftPanel.add(semanticIdentifier);
@ -182,11 +173,32 @@ public class SimilarGRSFRecordWidget extends Composite {
vpLeft.getElement().getStyle().setMarginLeft(15, Unit.PX); vpLeft.getElement().getStyle().setMarginLeft(15, Unit.PX);
vpLeft.setWidth("80%"); vpLeft.setWidth("80%");
Paragraph semanticIdentifier = new Paragraph("Semantic Identifier:"); Paragraph semanticIdentifier = new Paragraph("Semantic Identifier:");
TextBox box = new TextBox(); final TextBox box = new TextBox();
box.setWidth("70%"); box.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
String currentText = box.getText().trim();
GWT.log("Text changed to " + currentText);
s.setSemanticIdentifier(currentText);
}
});
box.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
String currentText = box.getText().trim();
GWT.log("Text changed to " + currentText);
s.setSemanticIdentifier(currentText);
}
});
box.setWidth("511px");
box.setPlaceholder("Insert the Semantic Identifier of the suggested record"); box.setPlaceholder("Insert the Semantic Identifier of the suggested record");
// TODO add handler for remote GRSF semantic id check
vpLeft.add(semanticIdentifier); vpLeft.add(semanticIdentifier);
vpLeft.add(box); vpLeft.add(box);
@ -221,9 +233,9 @@ public class SimilarGRSFRecordWidget extends Composite {
// remove this object from the pairs list // remove this object from the pairs list
Iterator<Pair> iterator = extraSimilarRecordsList.iterator(); Iterator<Pair> iterator = extraSimilarRecordsList.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
SimilarGRSFRecordWidget.Pair pair = (SimilarGRSFRecordWidget.Pair) iterator Pair pair = (Pair) iterator
.next(); .next();
if(pair.getS().equals(s)){ if(pair.getO().equals(s)){
pair.getW().removeFromParent(); pair.getW().removeFromParent();
iterator.remove(); iterator.remove();
} }
@ -246,19 +258,17 @@ public class SimilarGRSFRecordWidget extends Composite {
* Get the whole of similar records * Get the whole of similar records
* @return * @return
*/ */
public List<SimilarGRSFRecord> getSuggestedRecords(){ public List<SimilarGRSFRecord> getSimilarRecords(){
if(availableGRSFSimilarRecords == null) if(availableGRSFSimilarRecords == null)
availableGRSFSimilarRecords = new ArrayList<SimilarGRSFRecord>(); availableGRSFSimilarRecords = new ArrayList<SimilarGRSFRecord>();
for (Pair p : extraSimilarRecordsList) { for (Pair p : extraSimilarRecordsList) {
availableGRSFSimilarRecords.add(p.getS()); availableGRSFSimilarRecords.add((SimilarGRSFRecord) p.getO());
} }
return availableGRSFSimilarRecords; return availableGRSFSimilarRecords;
} }
} }

View File

@ -1,11 +1,6 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"> xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<g:HTMLPanel width="100%"> <g:HTMLPanel width="100%">
<g:VerticalPanel width="100%" ui:field="sourcesInnerPanel"></g:VerticalPanel> <g:VerticalPanel width="100%" ui:field="sourcesInnerPanel"></g:VerticalPanel>
</g:HTMLPanel> </g:HTMLPanel>

View File

@ -149,9 +149,9 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
similarRecords.add(Utils.similarGRSFRecordFromJson(similarGRSFRecord)); similarRecords.add(Utils.similarGRSFRecordFromJson(similarGRSFRecord));
} }
} }
logger.debug("SimilarGRSFRecords are " + similarRecords); logger.debug("SimilarGRSFRecords are " + similarRecords);
// Get sources // Get sources
List<CkanResource> resources = record.getResources(); List<CkanResource> resources = record.getResources();
List<SourceRecord> sources = new ArrayList<SourceRecord>(3); List<SourceRecord> sources = new ArrayList<SourceRecord>(3);
@ -221,4 +221,40 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
return false; return false;
} }
@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

@ -528,6 +528,8 @@ public class Utils {
logger.warn(message); logger.warn(message);
throw new Exception(message); throw new Exception(message);
} }
logger.info("Result size is " + datasets.size());
if(datasets.size() == 1) if(datasets.size() == 1)
return datasets.get(0); return datasets.get(0);
@ -536,8 +538,10 @@ public class Utils {
// worst situation.. we need to check for the right one // worst situation.. we need to check for the right one
for(CkanDataset dataset: datasets) for(CkanDataset dataset: datasets)
for(CkanPair extra : dataset.getExtras()) for(CkanPair extra : dataset.getExtras())
if(extra.getKey().contains(Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY) && extra.getValue().equals(suggestedRecordSemanticIdentifier)) 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; return dataset;
}
} }

View File

@ -0,0 +1,55 @@
package org.gcube.datacatalogue.grsf_manage_widget.shared;
/**
* Connect the current record with another record
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class ConnectBean {
private String sourceIdentifier;
private String sourceDomain; // i.e. Stock or Fishery
private String destSemanticIdentifier; // the dest semantic indentifier of a Fishery or Stock (the link is from a Stock to a Fishery and viceversa)
public ConnectBean() {
super();
}
/**
* @param sourceIdentifier
* @param sourceDomain
* @param destSemanticIdentifier
*/
public ConnectBean(String sourceIdentifier, String sourceDomain,
String destSemanticIdentifier) {
super();
this.sourceIdentifier = sourceIdentifier;
this.sourceDomain = sourceDomain;
this.destSemanticIdentifier = destSemanticIdentifier;
}
public String getSourceIdentifier() {
return sourceIdentifier;
}
public void setSourceIdentifier(String sourceIdentifier) {
this.sourceIdentifier = sourceIdentifier;
}
public String getDestSemanticIdentifier() {
return destSemanticIdentifier;
}
public void setDestSemanticIdentifier(String destSemanticIdentifier) {
this.destSemanticIdentifier = destSemanticIdentifier;
}
public String getSourceDomain() {
return sourceDomain;
}
public void setSourceDomain(String sourceDomain) {
this.sourceDomain = sourceDomain;
}
@Override
public String toString() {
return "ConnectBean [sourceIdentifier=" + sourceIdentifier
+ ", sourceDomain=" + sourceDomain
+ ", destSemanticIdentifier=" + destSemanticIdentifier + "]";
}
}

View File

@ -28,6 +28,7 @@ public class ManageProductBean implements Serializable{
private Map<String, String> extrasIfAvailable; // read from GRSFManageEntries resource 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<ConnectBean> connectTo;
public ManageProductBean() { public ManageProductBean() {
super(); super();
@ -180,35 +181,26 @@ public class ManageProductBean implements Serializable{
this.shortNameUpdated = shortNameUpdated; this.shortNameUpdated = shortNameUpdated;
} }
@Override public List<ConnectBean> getConnectTo() {
public String toString() { return connectTo;
return "ManageProductBean ["
+ (semanticIdentifier != null ? "semanticIdentifier="
+ semanticIdentifier + ", " : "")
+ (catalogueIdentifier != null ? "catalogueIdentifier="
+ catalogueIdentifier + ", " : "")
+ (knowledgeBaseIdentifier != null ? "knowledgeBaseIdentifier="
+ knowledgeBaseIdentifier + ", " : "")
+ (grsfType != null ? "grsfType=" + grsfType + ", " : "")
+ (grsfDomain != null ? "grsfDomain=" + grsfDomain + ", " : "")
+ (grsfName != null ? "grsfName=" + grsfName + ", " : "")
+ (shortName != null ? "shortName=" + shortName + ", " : "")
+ (shortNameUpdated != null ? "shortNameUpdated="
+ shortNameUpdated + ", " : "")
+ "traceabilityFlag="
+ traceabilityFlag
+ ", "
+ (currentStatus != null ? "currentStatus=" + currentStatus
+ ", " : "")
+ (newStatus != null ? "newStatus=" + newStatus + ", " : "")
+ (annotation != null ? "annotation=" + annotation + ", " : "")
+ (extrasIfAvailable != null ? "extrasIfAvailable="
+ extrasIfAvailable + ", " : "")
+ (sources != null ? "sources=" + sources + ", " : "")
+ (similarGrsfRecords != null ? "similarGrsfRecords="
+ similarGrsfRecords : "") + "]";
} }
public void setConnectTo(List<ConnectBean> connectTo) {
this.connectTo = connectTo;
}
@Override
public String toString() {
return "ManageProductBean [semanticIdentifier=" + semanticIdentifier
+ ", catalogueIdentifier=" + catalogueIdentifier
+ ", knowledgeBaseIdentifier=" + knowledgeBaseIdentifier
+ ", grsfType=" + grsfType + ", grsfDomain=" + grsfDomain
+ ", grsfName=" + grsfName + ", shortName=" + shortName
+ ", shortNameUpdated=" + shortNameUpdated
+ ", traceabilityFlag=" + traceabilityFlag + ", currentStatus="
+ currentStatus + ", newStatus=" + newStatus + ", annotation="
+ annotation + ", extrasIfAvailable=" + extrasIfAvailable
+ ", sources=" + sources + ", similarGrsfRecords="
+ similarGrsfRecords + ", connectTo=" + connectTo + "]";
}
} }

View File

@ -1,34 +1,6 @@
/** Add css rules here for your application. */ .error-text-box {
border: 1px solid red;
background: white url("../img/validation_error_icon.gif")
/** Example rules used by the template application (remove for your app) */ no-repeat left center;
h1 { padding-left: 15px !important;
font-size: 2em; }
font-weight: bold;
color: #777777;
margin: 40px 0px 70px;
text-align: center;
}
.sendButton {
display: block;
font-size: 16pt;
}
/** Most GWT widgets already have a style name defined */
.gwt-DialogBox {
width: 400px;
}
.dialogVPanel {
margin: 5px;
}
.serverResponseLabelError {
color: red;
}
/** Set ids using widget.getElement().setId("idOfElement") */
#closeButton {
margin: 15px 6px 6px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B