improved generic resource usage

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/grsf-manage-widget@142777 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-02-20 15:16:57 +00:00
parent 8a3110e337
commit e24efc16f6
5 changed files with 104 additions and 144 deletions

View File

@ -30,7 +30,7 @@ public class FormEntryModel extends Composite{
public FormEntryModel(String label, String value) {
initWidget(uiBinder.createAndBindUi(this));
labelEntry.add(new HTML("<b>" + label + "</b>"));
labelEntry.add(new HTML("<b>Item " + label + ":</b>"));
entryValue.setText(value);
}

View File

@ -55,21 +55,21 @@ public class ManageProductWidget extends Composite{
@UiField
TextArea titleTextArea;
@UiField
TextBox productType;
@UiField
TextBox productGrsfType;
@UiField
TextBox productSemanticId;
@UiField
TextBox productShortTitle;
// @UiField
// TextBox productType;
@UiField
TextBox productSource;
TextBox productGrsfType;
// @UiField
// TextBox productSemanticId;
//
// @UiField
// TextBox productShortTitle;
//
// @UiField
// TextBox productSource;
@UiField
TextBox currentStatus;
@ -91,12 +91,12 @@ public class ManageProductWidget extends Composite{
@UiField
ControlGroup listBoxStatusGroup;
@UiField
ControlGroup annotationAreaGroup;
@UiField
ControlGroup productTypeGroup;
ControlGroup productGrsfTypeGroup;
@UiField
Form formUpdate;
@ -130,7 +130,7 @@ public class ManageProductWidget extends Composite{
loadingImage.setVisible(true);
manageProductModal.show();
// async request to fetch the product
retrieveProductBean(productIdentifier);
}
@ -144,9 +144,9 @@ public class ManageProductWidget extends Composite{
public void onSuccess(Boolean result) {
if(!result){
showInfo(NO_ADMIN_ROLE, AlertType.ERROR);
// hide the form and disable the send button
formUpdate.setVisible(false);
confirmButton.setEnabled(false);
@ -162,19 +162,19 @@ public class ManageProductWidget extends Composite{
bean = result;
annotationArea.setText("");
infoBlock.setVisible(false);
titleTextArea.setText(bean.getItemTitle());
currentStatus.setText(bean.getCurrentStatus().toString());
productGrsfType.setText(bean.getGrsfType());
productType.setText(bean.getType());
productSemanticId.setText(bean.getSemanticId());
productShortTitle.setText(bean.getShortTitle());
productSource.setText(bean.getSource());
// productType.setText(bean.getType());
// productSemanticId.setText(bean.getSemanticId());
// productShortTitle.setText(bean.getShortTitle());
// productSource.setText(bean.getSource());
// check if we need to show more
if(bean.getExtrasIfAvailable() != null && !bean.getExtrasIfAvailable().isEmpty())
addExtrasAfter(bean, productTypeGroup);
addExtrasAfter(bean, productGrsfTypeGroup);
List<GRSFStatus> statusToShow = new ArrayList<GRSFStatus>(STATUS);
statusToShow.remove(bean.getCurrentStatus());
listBoxStatus.addItem("Select the new status");
@ -213,9 +213,9 @@ public class ManageProductWidget extends Composite{
@Override
public void onFailure(Throwable caught) {
showInfo(NO_ADMIN_ROLE, AlertType.ERROR);
// hide the form and disable the send button
formUpdate.setVisible(false);
confirmButton.setEnabled(false);
@ -225,7 +225,7 @@ public class ManageProductWidget extends Composite{
});
}
/**
* Add extras if available after controlGroupBefore
* @param bean
@ -233,20 +233,20 @@ public class ManageProductWidget extends Composite{
*/
private void addExtrasAfter(ManageProductBean bean,
ControlGroup controlGroupBefore) {
int index = formUpdate.getWidgetIndex(controlGroupBefore);
Map<String, String> extras = bean.getExtrasIfAvailable();
Iterator<Entry<String, String>> iterator = extras.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<java.lang.String, java.lang.String> entry = (Map.Entry<java.lang.String, java.lang.String>) iterator
.next();
formUpdate.insert(new FormEntryModel(entry.getKey(), entry.getValue()), index);
index++;
}
}
@UiHandler("cancelButton")
@ -266,9 +266,9 @@ public class ManageProductWidget extends Composite{
listBoxStatusGroup.setType(ControlGroupType.ERROR);
return;
}
annotationAreaGroup.setType(ControlGroupType.NONE);
if(annotationArea.getText() == null || annotationArea.getText().isEmpty()){
annotationArea.setPlaceholder("An annotation message to send along the update (mandatory)");
annotationAreaGroup.setType(ControlGroupType.ERROR);

View File

@ -44,45 +44,45 @@
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="productSemanticIdGroup">
<b:ControlLabel for="productSemanticId" title="The semantic id">
<b>Item Semantic Id:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox b:id="productSemanticId" alternateSize="LARGE"
width="97%" title="The semantic id" enabled="false" ui:field="productSemanticId"></b:TextBox>
</b:Controls>
</b:ControlGroup>
<!-- <b:ControlGroup ui:field="productSemanticIdGroup"> -->
<!-- <b:ControlLabel for="productSemanticId" title="The semantic id"> -->
<!-- <b>Item Semantic Id:</b> -->
<!-- </b:ControlLabel> -->
<!-- <b:Controls> -->
<!-- <b:TextBox b:id="productSemanticId" alternateSize="LARGE" -->
<!-- width="97%" title="The semantic id" enabled="false" ui:field="productSemanticId"></b:TextBox> -->
<!-- </b:Controls> -->
<!-- </b:ControlGroup> -->
<b:ControlGroup ui:field="productShortTitleGroup">
<b:ControlLabel for="productShortTitle" title="The short title">
<b>Item Short Title:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox b:id="productShortTitle" alternateSize="LARGE"
width="97%" title="The short title" enabled="false" ui:field="productShortTitle"></b:TextBox>
</b:Controls>
</b:ControlGroup>
<!-- <b:ControlGroup ui:field="productShortTitleGroup"> -->
<!-- <b:ControlLabel for="productShortTitle" title="The short title"> -->
<!-- <b>Item Short Title:</b> -->
<!-- </b:ControlLabel> -->
<!-- <b:Controls> -->
<!-- <b:TextBox b:id="productShortTitle" alternateSize="LARGE" -->
<!-- width="97%" title="The short title" enabled="false" ui:field="productShortTitle"></b:TextBox> -->
<!-- </b:Controls> -->
<!-- </b:ControlGroup> -->
<b:ControlGroup ui:field="productSourceGroup">
<b:ControlLabel for="productSource" title="The sources">
<b>Item Sources:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox b:id="productSource" alternateSize="LARGE"
width="97%" title="The sources" enabled="false" ui:field="productSource"></b:TextBox>
</b:Controls>
</b:ControlGroup>
<!-- <b:ControlGroup ui:field="productSourceGroup"> -->
<!-- <b:ControlLabel for="productSource" title="The sources"> -->
<!-- <b>Item Sources:</b> -->
<!-- </b:ControlLabel> -->
<!-- <b:Controls> -->
<!-- <b:TextBox b:id="productSource" alternateSize="LARGE" -->
<!-- width="97%" title="The sources" enabled="false" ui:field="productSource"></b:TextBox> -->
<!-- </b:Controls> -->
<!-- </b:ControlGroup> -->
<b:ControlGroup ui:field="productTypeGroup">
<b:ControlLabel for="productType" title="The Item type">
<b>Item Type:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox b:id="productType" alternateSize="LARGE"
width="97%" title="The Item type" enabled="false" ui:field="productType"></b:TextBox>
</b:Controls>
</b:ControlGroup>
<!-- <b:ControlGroup ui:field="productTypeGroup"> -->
<!-- <b:ControlLabel for="productType" title="The Item type"> -->
<!-- <b>Item Type:</b> -->
<!-- </b:ControlLabel> -->
<!-- <b:Controls> -->
<!-- <b:TextBox b:id="productType" alternateSize="LARGE" -->
<!-- width="97%" title="The Item type" enabled="false" ui:field="productType"></b:TextBox> -->
<!-- </b:Controls> -->
<!-- </b:ControlGroup> -->
<b:ControlGroup ui:field="currentStatusGroup">
<b:ControlLabel for="currentStatus"

View File

@ -66,10 +66,10 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
// info of the record to be shown at client-side
private static final String STATUS_CUSTOM_FIELD_KEY = "Status";
private static final String KB_UUID_FIELD_KEY = "UUID Knowledge Base";
private static final String TYPE_FIELD_KEY = "Type";
// private static final String TYPE_FIELD_KEY = "Type";
private static final String GRSF_TYPE_FIELD_KEY = "GRSF type";
private static final String SHORT_TITLE_FIELD_KEY = "Short Title";
private static final String SOURCES_TITLE_FIELD_KEY = "Source";
// private static final String SHORT_TITLE_FIELD_KEY = "Short Title";
// private static final String SOURCES_TITLE_FIELD_KEY = "Source";
// request post fields FORTH Service
private static final String CATALOGUE_ID = "catalog_id";
@ -157,7 +157,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
else{
toReturn = new ManageProductBean();
// check it is a grsf item, else..
List<CkanGroup> groups = product.getGroups();
boolean isGrsf = false;
@ -177,13 +177,13 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
Map<String, String> extras = product.getExtrasAsHashMap();
String status = extras.get(STATUS_CUSTOM_FIELD_KEY);
String uuidKB = extras.get(KB_UUID_FIELD_KEY);
String productType = extras.get(TYPE_FIELD_KEY);
// String productType = extras.get(TYPE_FIELD_KEY);
String productGRSFType = extras.get(GRSF_TYPE_FIELD_KEY);
String semanticId = extras.get(productGRSFType + " id"); // i.e "Stock id" or "Fishery id"
String shortTitle = extras.get(SHORT_TITLE_FIELD_KEY);
String sources = extras.get(SOURCES_TITLE_FIELD_KEY);
// String semanticId = extras.get(productGRSFType + " id"); // i.e "Stock id" or "Fishery id"
// String shortTitle = extras.get(SHORT_TITLE_FIELD_KEY);
// String sources = extras.get(SOURCES_TITLE_FIELD_KEY);
String title = product.getTitle();
// fetch extras
GenericResourceReaderExtras entries = new GenericResourceReaderExtras();
Set<String> extrasToShow = entries.getLookedUpExtrasKeys();
@ -199,17 +199,17 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
if(status == null || uuidKB == null)
throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge_base_uuid = " + uuidKB +
", and grsf type is = " + productType);
", and grsf type is = " + productGRSFType);
toReturn.setCatalogueIdentifier(productIdentifier);
toReturn.setCurrentStatus(GRSFStatus.fromString(status));
toReturn.setKnowledgeBaseIdentifier(uuidKB);
toReturn.setItemTitle(title);
toReturn.setGrsfType(productGRSFType);
toReturn.setType(productType);
toReturn.setSemanticId(semanticId);
toReturn.setShortTitle(shortTitle);
toReturn.setSource(sources);
// toReturn.setType(productType);
// toReturn.setSemanticId(semanticId);
// toReturn.setShortTitle(shortTitle);
// toReturn.setSource(sources);
logger.info("Returning item bean " + toReturn);

View File

@ -11,13 +11,13 @@ public class ManageProductBean implements Serializable{
private static final long serialVersionUID = -4882608487467259326L;
private String itemTitle;
private String semanticId; // Stock id or Fishery id
private String shortTitle;
// private String semanticId; // Stock id or Fishery id
// private String shortTitle;
private String catalogueIdentifier;
private String knowledgeBaseIdentifier;
private String type; // Fishery or Stock type (e.g., Assessment_Unit, Marine Resource and so on)
// private String type; // Fishery or Stock type (e.g., Assessment_Unit, Marine Resource and so on)
private String grsfType; // fishery/stock
private String source; // the current source
// private String source; // the current source
private Map<String, String> extrasIfAvailable;
// info that could change
@ -31,38 +31,31 @@ public class ManageProductBean implements Serializable{
/**
* @param itemTitle
* @param semanticId
* @param shortTitle
* @param catalogueIdentifier
* @param knowledgeBaseIdentifier
* @param type
* @param grsfType
* @param source
* @param extrasIfAvailable
* @param currentStatus
* @param newStatus
* @param annotation
*/
public ManageProductBean(String itemTitle, String semanticId,
String shortTitle, String catalogueIdentifier,
String knowledgeBaseIdentifier, String type, String grsfType,
String source, Map<String, String> extrasIfAvailable,
GRSFStatus currentStatus, GRSFStatus newStatus, String annotation) {
public ManageProductBean(String itemTitle, String catalogueIdentifier,
String knowledgeBaseIdentifier, String grsfType,
Map<String, String> extrasIfAvailable, GRSFStatus currentStatus,
GRSFStatus newStatus, String annotation) {
super();
this.itemTitle = itemTitle;
this.semanticId = semanticId;
this.shortTitle = shortTitle;
this.catalogueIdentifier = catalogueIdentifier;
this.knowledgeBaseIdentifier = knowledgeBaseIdentifier;
this.type = type;
this.grsfType = grsfType;
this.source = source;
this.extrasIfAvailable = extrasIfAvailable;
this.currentStatus = currentStatus;
this.newStatus = newStatus;
this.annotation = annotation;
}
public String getCatalogueIdentifier() {
return catalogueIdentifier;
}
@ -110,14 +103,6 @@ public class ManageProductBean implements Serializable{
this.itemTitle = itemTitle;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getGrsfType() {
return grsfType;
}
@ -126,30 +111,6 @@ public class ManageProductBean implements Serializable{
this.grsfType = grsfType;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getSemanticId() {
return semanticId;
}
public void setSemanticId(String semanticId) {
this.semanticId = semanticId;
}
public String getShortTitle() {
return shortTitle;
}
public void setShortTitle(String shortTitle) {
this.shortTitle = shortTitle;
}
public Map<String, String> getExtrasIfAvailable() {
return extrasIfAvailable;
}
@ -160,14 +121,13 @@ public class ManageProductBean implements Serializable{
@Override
public String toString() {
return "ManageProductBean [itemTitle=" + itemTitle + ", semanticId="
+ semanticId + ", shortTitle=" + shortTitle
return "ManageProductBean [itemTitle=" + itemTitle
+ ", catalogueIdentifier=" + catalogueIdentifier
+ ", knowledgeBaseIdentifier=" + knowledgeBaseIdentifier
+ ", type=" + type + ", grsfType=" + grsfType + ", source="
+ source + ", extrasIfAvailable=" + extrasIfAvailable
+ ", currentStatus=" + currentStatus + ", newStatus="
+ newStatus + ", annotation=" + annotation + "]";
+ ", grsfType=" + grsfType + ", extrasIfAvailable="
+ extrasIfAvailable + ", currentStatus=" + currentStatus
+ ", newStatus=" + newStatus + ", annotation=" + annotation
+ "]";
}
}