improved set of information shown by the widget: title, short title, semantic id, grsf type, type, source(s)

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/grsf-manage-widget@142737 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-02-19 15:41:36 +00:00
parent d3d96333d4
commit 78d650512c
4 changed files with 144 additions and 55 deletions

View File

@ -23,7 +23,7 @@ public interface GRSFManageWidgetService extends RemoteService {
ManageProductBean getProductBeanById(String identifier) throws Exception;
/**
* check if the user has the role to manage the item
* check if the user has the rights to manage the item
*/
boolean isAdminUser();
}

View File

@ -51,7 +51,22 @@ public class ManageProductWidget extends Composite{
AlertBlock infoBlock;
@UiField
TextArea nameTextArea;
TextArea titleTextArea;
@UiField
TextBox productType;
@UiField
TextBox productGrsfType;
@UiField
TextBox productSemanticId;
@UiField
TextBox productShortTitle;
@UiField
TextBox productSource;
@UiField
TextBox currentStatus;
@ -77,9 +92,6 @@ public class ManageProductWidget extends Composite{
@UiField
Form formUpdate;
@UiField
TextBox productType;
@UiField
Image loadingImage;
@ -141,9 +153,15 @@ public class ManageProductWidget extends Composite{
bean = result;
annotationArea.setText("");
infoBlock.setVisible(false);
nameTextArea.setText(bean.getItemTitle());
titleTextArea.setText(bean.getItemTitle());
currentStatus.setText(bean.getCurrentStatus().toString());
productType.setText(bean.getGrsfType());
productGrsfType.setText(bean.getGrsfType());
productType.setText(bean.getType());
productSemanticId.setText(bean.getSemanticId());
productShortTitle.setText(bean.getShortTitle());
productSource.setText(bean.getSource());
List<GRSFStatus> statusToShow = new ArrayList<GRSFStatus>(STATUS);
statusToShow.remove(bean.getCurrentStatus());
listBoxStatus.addItem("Select the new status");

View File

@ -20,23 +20,75 @@
<b:AlertBlock type="INFO" close="false" animation="true"
visible="false" ui:field="infoBlock"></b:AlertBlock>
<b:Form type="VERTICAL" visible="true" ui:field="formUpdate" width="100%">
<b:Form type="VERTICAL" visible="true" ui:field="formUpdate"
width="100%">
<b:ControlGroup ui:field="productTitleGroup">
<b:ControlLabel for="name" title="Item name">
<b>Item Name:</b>
<b:ControlLabel for="titel" title="Item title">
<b>Item title:</b>
</b:ControlLabel>
<b:Controls>
<b:TextArea alternateSize="LARGE" placeholder="Item name"
enabled="false" width="97%" b:id="name" title="Item name"
ui:field="nameTextArea" />
<b:TextArea alternateSize="LARGE" placeholder="Item title"
enabled="false" width="97%" b:id="name" title="Item title"
ui:field="titleTextArea" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="productGrsfTypeGroup">
<b:ControlLabel for="productGrsfType" title="The GRSF Item type">
<b>Item GRSF Type:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox b:id="productGrsfType" alternateSize="LARGE"
width="97%" title="The GRSF Item type" enabled="false" ui:field="productGrsfType"></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="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="currentStatusGroup">
<b:ControlLabel for="currentStatus"
title="The current status of this Item">
<b>Item Current Status:</b></b:ControlLabel>
<b>Item Current Status:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox b:id="currentStatus" alternateSize="LARGE"
enabled="false" width="97%" title="The current status of this Item"
@ -46,30 +98,20 @@
</b:ControlGroup>
<b:ControlGroup ui:field="listBoxStatusGroup">
<b:ControlLabel for="listboxStatus"
title="The new status of this Item">
<b>Item New Status:</b></b:ControlLabel>
<b:ControlLabel for="listboxStatus" title="The new status of this Item">
<b>Item New Status:</b>
</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="listboxStatus" alternateSize="LARGE"
width="97%" title="Select a new status" enabled="true"
ui:field="listBoxStatus"></b:ListBox>
</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>
width="97%" title="Select a new status" enabled="true" ui:field="listBoxStatus"></b:ListBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="annotationAreaGroup">
<b:ControlLabel for="annotation"
title="An annotation message to send along the update">
<b>Annotation:</b></b:ControlLabel>
<b>Annotation:</b>
</b:ControlLabel>
<b:Controls>
<b:TextArea b:id="annotation" alternateSize="LARGE"
placeholder="Add an annotation message" enabled="true" width="97%"

View File

@ -59,9 +59,16 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
private static final Log logger = LogFactoryUtil.getLog(GRSFNotificationService.class);
private static final String ANNOTATION_KEY = "Annotation on update";
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final String STATUS_CUSTOM_FIELD_KEY = "Status";
private static final int MAX_TRIAL = 5;
// 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 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";
// request post fields FORTH Service
private static final String CATALOGUE_ID = "catalog_id";
private static final String KB_ID = "record_id";
@ -69,7 +76,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
private static final String STATUS = "status";
private static final String ANNOTATION = "annotation_msg";
private static final String ERROR = "error";
// discover the endpoint of the grsf updater on IS
public static final String GRSF_UPDATER_SERVICE = "GRSFUpdaterEndPoint";
private static final String SERVICE_POST_METHOD = "/service/updater/post";
@ -142,33 +149,55 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
String username = getCurrentUser(getThreadLocalRequest()).getUsername();
CkanDataset product = catalogue.getDataset(productIdentifier, catalogue.getApiKeyFromUsername(username));
// get extras
Map<String, String> extras = product.getExtrasAsHashMap();
String status = extras.get("Status");
String uuidKB = extras.get("UUID Knowledge Base");
String productType = extras.get("Product type");
String recordType = extras.get("Record type");
String title = product.getTitle();
// it cannot be enabled in this case ...
if(recordType == null || recordType.equals("Source"))
throw new NoGRSFRecordException("This is not a GRSF Item");
if(product == null)
throw new Exception("Unable to retrieve information for the selected item, sorry");
else{
if(status == null || uuidKB == null || productType == null)
throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge_base_uuid = " + uuidKB +
", and product type is = " + productType);
// check it is a grsf item, else..
List<CkanGroup> groups = product.getGroups();
boolean isGrsf = false;
for (CkanGroup ckanGroup : groups) {
if(ckanGroup.getName().contains("grsf")){
isGrsf = true;
break;
}
}
toReturn = new ManageProductBean();
toReturn.setCatalogueIdentifier(productIdentifier);
toReturn.setCurrentStatus(GRSFStatus.fromString(status));
toReturn.setKnowledgeBaseIdentifier(uuidKB);
toReturn.setItemTitle(title);
toReturn.setGrsfType(productType);
if(!isGrsf)
throw new NoGRSFRecordException("This is not a GRSF Item");
logger.info("Returning item bean " + toReturn);
// get extras
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 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 title = product.getTitle();
if(status == null || uuidKB == null || productGRSFType == null)
throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge_base_uuid = " + uuidKB +
", and grsf type is = " + productType);
return toReturn;
toReturn = new ManageProductBean();
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);
logger.info("Returning item bean " + toReturn);
return toReturn;
}
}
/**
@ -432,7 +461,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
return httpServletRequest.getHeader(GCUBE_REQUEST_URL);
}
/**
* Retrieve the current scope by using the portal manager
* @param b