when a time interval is not mandatory, the user can insert a start time and leave empty the end time but not viceversa. Of course it can leave empty them both at the same time
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@133599 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
18be286f8b
commit
173933bc5c
|
@ -87,8 +87,9 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
private static final String DELETE_TIME_RANGE = "Delete the last Time Range";
|
private static final String DELETE_TIME_RANGE = "Delete the last Time Range";
|
||||||
|
|
||||||
// missing range value
|
// missing range value
|
||||||
private static final String INSERT_MISSING_VALUE = " one or more range value missing";
|
private static final String INSERT_MISSING_VALUE = " you cannot specify an end date without a start one";
|
||||||
private static final String INSERT_MISSING_VALUE_MANDATORY = " one or more range value missing in mandatory attribute";
|
private static final String INSERT_MISSING_VALUE_MANDATORY = " one or more range value missing in mandatory attribute";
|
||||||
|
private static final String UPPER_RANGE_NOT_SPECIFIED = "Not specified";
|
||||||
// time range separator
|
// time range separator
|
||||||
public static final String RANGE_SEPARATOR = ",";
|
public static final String RANGE_SEPARATOR = ",";
|
||||||
|
|
||||||
|
@ -383,12 +384,13 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
String rangeValue = rangesList.get(0).getCurrentValue();
|
String rangeValue = rangesList.get(0).getCurrentValue();
|
||||||
|
|
||||||
if(field.getMandatory()){
|
if(field.getMandatory()){
|
||||||
if(rangeValue.contains(DataTimeBox.MISSING_RANGE_VALUE))
|
if(rangeValue.contains(DataTimeBox.MISSING_RANGE_VALUE_START) || rangeValue.contains(DataTimeBox.MISSING_RANGE_VALUE_END))
|
||||||
return INSERT_MISSING_VALUE_MANDATORY;
|
return INSERT_MISSING_VALUE_MANDATORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rangeValue.contains(DataTimeBox.MISSING_RANGE_VALUE) && !rangeValue.equals(DataTimeBox.MISSING_RANGE_VALUE + DataTimeBox.RANGE_SEPARATOR_START_END + DataTimeBox.MISSING_RANGE_VALUE))
|
if(rangeValue.contains(DataTimeBox.MISSING_RANGE_VALUE_START) && !rangeValue.equals(DataTimeBox.MISSING_RANGE_VALUE_START + DataTimeBox.RANGE_SEPARATOR_START_END + DataTimeBox.MISSING_RANGE_VALUE_END))
|
||||||
return INSERT_MISSING_VALUE;
|
return INSERT_MISSING_VALUE;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
case Times_ListOf:
|
case Times_ListOf:
|
||||||
|
@ -397,12 +399,12 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
|
|
||||||
String currentValue = el.getCurrentValue();
|
String currentValue = el.getCurrentValue();
|
||||||
if(field.getMandatory()){
|
if(field.getMandatory()){
|
||||||
if(currentValue.contains(DataTimeBox.MISSING_RANGE_VALUE))
|
if(currentValue.contains(DataTimeBox.MISSING_RANGE_VALUE_START) || currentValue.contains(DataTimeBox.MISSING_RANGE_VALUE_END))
|
||||||
return INSERT_MISSING_VALUE_MANDATORY;
|
return INSERT_MISSING_VALUE_MANDATORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
GWT.log("Printing " + currentValue);
|
GWT.log("Printing " + currentValue);
|
||||||
if(currentValue.contains(DataTimeBox.MISSING_RANGE_VALUE) && !currentValue.equals(DataTimeBox.MISSING_RANGE_VALUE + DataTimeBox.RANGE_SEPARATOR_START_END + DataTimeBox.MISSING_RANGE_VALUE))
|
if(currentValue.contains(DataTimeBox.MISSING_RANGE_VALUE_START) && !currentValue.equals(DataTimeBox.MISSING_RANGE_VALUE_START + DataTimeBox.RANGE_SEPARATOR_START_END + DataTimeBox.MISSING_RANGE_VALUE_END))
|
||||||
return INSERT_MISSING_VALUE;
|
return INSERT_MISSING_VALUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -509,17 +511,17 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
|
|
||||||
case Time:
|
case Time:
|
||||||
|
|
||||||
toReturn = ((DataTimeBox)holder).getCurrentValue().replaceAll(DataTimeBox.MISSING_RANGE_VALUE, "");
|
toReturn = ((DataTimeBox)holder).getCurrentValue().replaceAll(DataTimeBox.MISSING_RANGE_VALUE_START, ""); // it was a noRange metadata
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Time_Interval:
|
case Time_Interval:
|
||||||
|
|
||||||
toReturn = rangesList.get(0).getCurrentValue().replaceAll(DataTimeBox.MISSING_RANGE_VALUE, "");
|
toReturn = rangesList.get(0).getCurrentValue().replaceAll(DataTimeBox.MISSING_RANGE_VALUE_START, "").replaceAll(DataTimeBox.MISSING_RANGE_VALUE_END, UPPER_RANGE_NOT_SPECIFIED);
|
||||||
if(toReturn.equals(DataTimeBox.RANGE_SEPARATOR_START_END))
|
if(toReturn.equals(DataTimeBox.RANGE_SEPARATOR_START_END + UPPER_RANGE_NOT_SPECIFIED))
|
||||||
toReturn = "";
|
toReturn = "";
|
||||||
|
|
||||||
// split to check if the extreme are equals
|
// split to check if the extreme are equals
|
||||||
String[] temp = toReturn.split("/");
|
String[] temp = toReturn.split(DataTimeBox.RANGE_SEPARATOR_START_END);
|
||||||
if(temp[0].equals(temp[1]))
|
if(temp[0].equals(temp[1]))
|
||||||
toReturn = temp[0];
|
toReturn = temp[0];
|
||||||
|
|
||||||
|
@ -530,8 +532,8 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
toReturn = "";
|
toReturn = "";
|
||||||
for (DataTimeBox elem : rangesList) {
|
for (DataTimeBox elem : rangesList) {
|
||||||
|
|
||||||
String currentRange = elem.getCurrentValue().replaceAll(DataTimeBox.MISSING_RANGE_VALUE, "");
|
String currentRange = elem.getCurrentValue().replaceAll(DataTimeBox.MISSING_RANGE_VALUE_START, "").replaceAll(DataTimeBox.MISSING_RANGE_VALUE_END, UPPER_RANGE_NOT_SPECIFIED);
|
||||||
if(currentRange.equals(DataTimeBox.RANGE_SEPARATOR_START_END))
|
if(currentRange.equals(DataTimeBox.RANGE_SEPARATOR_START_END + UPPER_RANGE_NOT_SPECIFIED))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String[] splitted = currentRange.split(DataTimeBox.RANGE_SEPARATOR_START_END);
|
String[] splitted = currentRange.split(DataTimeBox.RANGE_SEPARATOR_START_END);
|
||||||
|
|
|
@ -21,7 +21,8 @@ public class DataTimeBox extends Composite{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String RANGE_SEPARATOR_START_END = "/";
|
public static final String RANGE_SEPARATOR_START_END = "/";
|
||||||
public static final String MISSING_RANGE_VALUE = "MISSING_RANGE_PART";
|
public static final String MISSING_RANGE_VALUE_START = "MISSING_RANGE_PART_START";
|
||||||
|
public static final String MISSING_RANGE_VALUE_END = "MISSING_RANGE_PART_END";
|
||||||
private static final String COLON = ":";
|
private static final String COLON = ":";
|
||||||
private static final String INSERT_DATE_INSTANT_LABEL = "Insert a date";
|
private static final String INSERT_DATE_INSTANT_LABEL = "Insert a date";
|
||||||
private static final String INSERT_TIME_INSTANT_LABEL = "Hour and minutes";
|
private static final String INSERT_TIME_INSTANT_LABEL = "Hour and minutes";
|
||||||
|
@ -102,8 +103,8 @@ public class DataTimeBox extends Composite{
|
||||||
*/
|
*/
|
||||||
public String getCurrentValue(){
|
public String getCurrentValue(){
|
||||||
|
|
||||||
String firstRange = MISSING_RANGE_VALUE;
|
String firstRange = MISSING_RANGE_VALUE_START;
|
||||||
String secondRange = MISSING_RANGE_VALUE;
|
String secondRange = MISSING_RANGE_VALUE_END;
|
||||||
|
|
||||||
if(startRangeDate.getValue() != null){
|
if(startRangeDate.getValue() != null){
|
||||||
firstRange = formatDate.format(startRangeDate.getValue()) + " " + (startRangeTime.getValue() != null ? formatTime.format(startRangeTime.getValue()) : "");;
|
firstRange = formatDate.format(startRangeDate.getValue()) + " " + (startRangeTime.getValue() != null ? formatTime.format(startRangeTime.getValue()) : "");;
|
||||||
|
|
Loading…
Reference in New Issue