fixed Similar to GRSF record field (now is set as json object)
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@154408 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b57e6c6f6d
commit
1393967788
|
@ -3,6 +3,9 @@
|
|||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<dependent-module archiveName="ckan-util-library-2.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="context-root" value="grsf-publisher-ws"/>
|
||||
<property name="java-output-path" value="/grsf-publisher-ws/target/classes"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -85,7 +85,7 @@ public class Common extends Base{
|
|||
@JsonProperty("similar_grsf_records")
|
||||
@CustomField(key="Similar GRSF Records")
|
||||
private List<SimilarRecordBean> similarGRSFRecords;
|
||||
|
||||
|
||||
@JsonProperty("similar_source_records")
|
||||
@CustomField(key="Similar Source Records")
|
||||
private List<SimilarRecordBean> similarSourceRecords;
|
||||
|
@ -241,6 +241,34 @@ public class Common extends Base{
|
|||
this.similarSourceRecords = similarSourceRecords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean the semantic id
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static String cleanSemanticId(String id){
|
||||
|
||||
if(id == null)
|
||||
return null;
|
||||
else{
|
||||
String idmodified = "";
|
||||
if(id != null){
|
||||
|
||||
String[] splitCodesValues = id.split("\\+");
|
||||
for (int i = 0; i < splitCodesValues.length; i++) {
|
||||
String prefixAndCode = splitCodesValues[i];
|
||||
String prefix = prefixAndCode.split(":")[0];
|
||||
String code = prefixAndCode.split(":")[1];
|
||||
idmodified += prefix.toLowerCase() + ":" + code.toUpperCase();
|
||||
if(splitCodesValues.length > 1 && i < (splitCodesValues.length - 1))
|
||||
idmodified += "+";
|
||||
}
|
||||
}
|
||||
return idmodified;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Common [dataOwner=" + dataOwner + ", databaseSources="
|
||||
|
|
|
@ -115,22 +115,7 @@ public class FisheryRecord extends Common{
|
|||
}
|
||||
|
||||
public void setFisheryId(String fisheryId) {
|
||||
String fisheryIdmodified = "";
|
||||
if(fisheryId != null){
|
||||
|
||||
String[] splitCodesValues = fisheryId.split("\\+");
|
||||
for (int i = 0; i < splitCodesValues.length; i++) {
|
||||
String prefixAndCode = splitCodesValues[i];
|
||||
String prefix = prefixAndCode.split(":")[0];
|
||||
String code = prefixAndCode.split(":")[1];
|
||||
fisheryIdmodified += prefix.toLowerCase() + ":" + code.toUpperCase();
|
||||
if(splitCodesValues.length > 1 && i < (splitCodesValues.length - 1))
|
||||
fisheryIdmodified += "+";
|
||||
}
|
||||
}
|
||||
|
||||
this.fisheryId = fisheryIdmodified;
|
||||
|
||||
this.fisheryId = super.cleanSemanticId(fisheryId);
|
||||
}
|
||||
|
||||
public List<String> getFishingArea() {
|
||||
|
|
|
@ -180,22 +180,7 @@ public class StockRecord extends Common{
|
|||
}
|
||||
|
||||
public void setStockId(String stockId) {
|
||||
|
||||
String stockIdmodified = "";
|
||||
if(stockId != null){
|
||||
|
||||
String[] splitCodesValues = stockId.split("\\+");
|
||||
for (int i = 0; i < splitCodesValues.length; i++) {
|
||||
String prefixAndCode = splitCodesValues[i];
|
||||
String prefix = prefixAndCode.split(":")[0];
|
||||
String code = prefixAndCode.split(":")[1];
|
||||
stockIdmodified += prefix.toLowerCase() + ":" + code.toUpperCase();
|
||||
if(splitCodesValues.length > 1 && i < (splitCodesValues.length - 1))
|
||||
stockIdmodified += "+";
|
||||
}
|
||||
}
|
||||
|
||||
this.stockId = stockIdmodified;
|
||||
this.stockId = super.cleanSemanticId(stockId);
|
||||
}
|
||||
|
||||
public List<String> getArea() {
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.FisheryRecord;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.utils.RefersToBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.utils.Resource;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.utils.SimilarRecordBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.utils.TimeSeriesBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Product_Type;
|
||||
|
@ -301,13 +302,28 @@ public class CommonServiceUtils {
|
|||
valuesForKey.add(clean);
|
||||
}
|
||||
|
||||
}else{
|
||||
}else if(asList.get(0).getClass().equals(SimilarRecordBean.class)){
|
||||
|
||||
for (int i = 0; i < asList.size(); i++) {
|
||||
SimilarRecordBean similarRecord = (SimilarRecordBean) asList.get(i);
|
||||
JSONObject obj = new JSONObject();
|
||||
if(similarRecord.getId() != null)
|
||||
obj.put("id", Common.cleanSemanticId(similarRecord.getId()));
|
||||
if(similarRecord.getDescription() != null)
|
||||
obj.put("description", similarRecord.getDescription());
|
||||
if(similarRecord.getUrl() != null)
|
||||
obj.put("url", similarRecord.getUrl() );
|
||||
valuesForKey.add(obj.toJSONString());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < elementsToConsider; i++) {
|
||||
String clean = HelperMethods.removeHTML(asList.get(i).toString().trim());
|
||||
valuesForKey.add(clean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
String clean = HelperMethods.removeHTML(f.toString().trim());
|
||||
valuesForKey.add(clean);
|
||||
|
@ -448,7 +464,7 @@ public class CommonServiceUtils {
|
|||
groups.add(sourceInPath.getOrigName().toLowerCase() + "-" + productType.getOrigName().toLowerCase()); //e.g. grsf-fishery
|
||||
boolean skipTags = !sourceInPath.equals(Sources.GRSF); // no tags for the Original records
|
||||
CommonServiceUtils.getTagsGroupsResourcesExtrasByRecord(tags, skipTags, groups, false, resources, false, customFields, record, username, sourceInPath);
|
||||
|
||||
|
||||
// set the system type type: fishery or stock
|
||||
record.setSystemType(productType.equals(Product_Type.STOCK)? SYSTEM_TYPE_STOCK : SYSTEM_TYPE_FISHERY);
|
||||
|
||||
|
|
Loading…
Reference in New Issue