connected bean object updated and timeseries to string result updated according to document https://docs.google.com/document/d/1q-WUWsgSZUVb_iMNoZV9udCuHN_qVVxaQ0EizosT7Lg

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@162684 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2018-01-26 15:52:44 +00:00
parent e02b55d6ab
commit c3738ffddd
2 changed files with 51 additions and 14 deletions

View File

@ -24,23 +24,44 @@ public class ConnectedBean {
@Size(min=1, message= Constants.CONNECTED_RECORD_KNOWLEDGE_BASE_ID_JSON_KEY + " cannot be empty")
private String knowledeBaseId;
@JsonProperty(Constants.CONNECTED_JSON_KEY)
private boolean connected;
public ConnectedBean() {
super();
}
/**
* @param semanticIdentifier
* @param shortName
* @param knowledeBaseId
* @param connected
*/
public ConnectedBean(String semanticIdentifier, String shortName,
String knowledeBaseId) {
String knowledeBaseId, boolean connected) {
super();
this.semanticIdentifier = semanticIdentifier;
this.shortName = shortName;
this.knowledeBaseId = knowledeBaseId;
this.connected = connected;
}
public boolean isConnected() {
return connected;
}
public void setConnected(boolean connected) {
this.connected = connected;
}
public String getSemanticIdentifier() {
return semanticIdentifier;
}
@ -70,14 +91,10 @@ public class ConnectedBean {
public String toString() {
JSONObject obj = new JSONObject();
obj.put(Constants.CONNECTED_RECORD_SHORT_NAME_JSON_KEY, shortName);
if(semanticIdentifier != null && !semanticIdentifier.isEmpty())
obj.put(Constants.CONNECTED_RECORD_SEMANTIC_IDENTIFIER_JSON_KEY, semanticIdentifier);
obj.put(Constants.CONNECTED_RECORD_SEMANTIC_IDENTIFIER_JSON_KEY, semanticIdentifier);
obj.put(Constants.CONNECTED_RECORD_KNOWLEDGE_BASE_ID_JSON_KEY, knowledeBaseId);
obj.put(Constants.CONNECTED_JSON_KEY, connected);
return obj.toJSONString();
}

View File

@ -120,7 +120,7 @@ public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
public boolean isValuePresent(){
return value != null && !value.getClass().equals(Void.class);
}
public boolean isDataOwnerPresent(){
return dataOwner != null && !dataOwner.isEmpty();
}
@ -135,14 +135,34 @@ public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
public String toString() {
String value = "" + this.value;
String unit = (this.unit != null ? " " + this.unit : "");
String databaseSource = (this.databaseSource != null ? " (" + this.databaseSource + ")" : "");
String dataOwner = (this.dataOwner != null ? " " + this.dataOwner : "");
String referenceYear = year >= 0 ? " Ref. Year " + year : "";
String reportingYearOrAssessment = (assessment != null ? " and Rep. Year or Assessment Id " + assessment + "" : "");
String unit = this.unit != null ? "Unit : " + this.unit : "";
String databaseSource = (this.databaseSource != null ? " - DB Source: " + this.databaseSource : "");
String dataOwner = (this.dataOwner != null ? " - Data Owner: " + this.dataOwner : "");
String referenceYear = year >= 0 ? " - Ref. Year: " + year : "";
String reportingYearOrAssessment = (assessment != null ? " - Rep. Year or Assessment Id: " + assessment + "" : "");
String partial = value + "[" +
unit +
reportingYearOrAssessment +
referenceYear +
dataOwner +
databaseSource +
"]";
return value + unit + databaseSource + dataOwner + referenceYear + reportingYearOrAssessment;
return partial.replaceAll("\\b\\[ - \\b", "[");
}
// public static void main(String[] args) {
//
// TimeSeriesBean<String, String> t = new TimeSeriesBean<String, String>();
// t.setYear(1021L);
// t.setDatabaseSource("tttt");
// t.setDataOwner("zzzz");
// t.setUnit("uuuu");
// t.setValue("vvvv");
// t.setAssessment("2015");
// System.err.println("Result is \n" + t);
//
// }
}