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="/target/m2e-wtp/web-resources"/>
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<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="context-root" value="grsf-publisher-ws"/>
|
||||||
<property name="java-output-path" value="/grsf-publisher-ws/target/classes"/>
|
<property name="java-output-path" value="/grsf-publisher-ws/target/classes"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
|
@ -241,6 +241,34 @@ public class Common extends Base{
|
||||||
this.similarSourceRecords = similarSourceRecords;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Common [dataOwner=" + dataOwner + ", databaseSources="
|
return "Common [dataOwner=" + dataOwner + ", databaseSources="
|
||||||
|
|
|
@ -115,22 +115,7 @@ public class FisheryRecord extends Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFisheryId(String fisheryId) {
|
public void setFisheryId(String fisheryId) {
|
||||||
String fisheryIdmodified = "";
|
this.fisheryId = super.cleanSemanticId(fisheryId);
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getFishingArea() {
|
public List<String> getFishingArea() {
|
||||||
|
|
|
@ -180,22 +180,7 @@ public class StockRecord extends Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStockId(String stockId) {
|
public void setStockId(String stockId) {
|
||||||
|
this.stockId = super.cleanSemanticId(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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getArea() {
|
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.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.RefersToBean;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.utils.Resource;
|
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.input.utils.TimeSeriesBean;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
|
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Product_Type;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Product_Type;
|
||||||
|
@ -301,13 +302,28 @@ public class CommonServiceUtils {
|
||||||
valuesForKey.add(clean);
|
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++) {
|
for (int i = 0; i < elementsToConsider; i++) {
|
||||||
String clean = HelperMethods.removeHTML(asList.get(i).toString().trim());
|
String clean = HelperMethods.removeHTML(asList.get(i).toString().trim());
|
||||||
valuesForKey.add(clean);
|
valuesForKey.add(clean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
String clean = HelperMethods.removeHTML(f.toString().trim());
|
String clean = HelperMethods.removeHTML(f.toString().trim());
|
||||||
valuesForKey.add(clean);
|
valuesForKey.add(clean);
|
||||||
|
|
Loading…
Reference in New Issue