From 60aa743347f1d7c099cc6fc34e4bc8a9eeaef983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 24 Nov 2019 21:16:39 +0100 Subject: Remove query from attribute submission --- .../java/pl/edu/mimuw/cloudatlas/client/ClientController.java | 8 +++----- .../pl/edu/mimuw/cloudatlas/client/templates/attribForm.html | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src/main') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java index 80a331e..a122813 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java @@ -94,6 +94,7 @@ public class ClientController { private Set parseContactsString(DataStringInput contactsInput) throws Exception { Gson gson = new Gson(); + System.out.println(contactsInput); Map contactStrings = gson.fromJson(contactsInput.getString(), Map.class); Set contactObjects = new HashSet(); ArrayList cAddr; @@ -147,6 +148,7 @@ public class ClientController { String currentTypeString = types.get(1); AttributeInput attributeInput = new AttributeInput(); ArrayList newTypes = new ArrayList<>(types.subList(1, types.size())); + Gson gson = new Gson(); for (int i = 0; i < values.size(); i++) { if (currentTypeString.equals("List")) { @@ -155,7 +157,7 @@ public class ClientController { resultValue.add(parseSetAttributeValue((List) values.get(i), newTypes)); } else { attributeInput.setAttributeType(currentTypeString); - attributeInput.setValueString(values.get(i).toString()); + attributeInput.setValueString(gson.toJson(values.get(i))); resultValue.add(parseAttributeValue(attributeInput)); } } @@ -208,10 +210,6 @@ public class ClientController { contactsString.setString(attributeObject.getValueString()); attributeValue = parseContactsString(contactsString).iterator().next(); break; - case "Query": - Map parsedQuery = gson.fromJson(attributeObject.getValueString(), Map.class); - attributeValue = new ValueQuery(attributeObject.getValueString()); - break; case "List": List parsedListValue = gson.fromJson(attributeObject.getValueString(), List.class); ArrayList parsedListTypes = new ArrayList<>(Arrays.asList( diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html index ed6dcd2..3740491 100644 --- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html +++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html @@ -30,7 +30,6 @@ - -- cgit v1.2.3 From b4632d58a3387b298a5352d08ebfddba5bbb76dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 24 Nov 2019 21:31:43 +0100 Subject: Improve value input for boolean attributes --- .../java/pl/edu/mimuw/cloudatlas/client/ClientController.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java index a122813..745550b 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java @@ -185,9 +185,14 @@ public class ClientController { switch (attributeObject.getAttributeType()) { case "Boolean": - attributeValue = attributeObject.getValueString().toLowerCase().equals("true") ? - new ValueBoolean(true) : - new ValueBoolean(false); + if (attributeObject.getValueString().toLowerCase().equals("true")) { + attributeValue = new ValueBoolean(true); + } else if (attributeObject.getValueString().toLowerCase().equals("false")) { + attributeValue = new ValueBoolean(false); + } else { + String errMsg = "Incorrect boolean value: " + attributeObject.getValueString(); + throw new UnsupportedOperationException(errMsg); + } break; case "Double": attributeValue = new ValueDouble(Double.parseDouble(attributeObject.getValueString())); -- cgit v1.2.3 From 1fbbfd3dd52146e64511552a2dbb5f35c62771c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 24 Nov 2019 21:38:08 +0100 Subject: Remove contact submission log --- src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java index 745550b..148fb8d 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java @@ -94,7 +94,6 @@ public class ClientController { private Set parseContactsString(DataStringInput contactsInput) throws Exception { Gson gson = new Gson(); - System.out.println(contactsInput); Map contactStrings = gson.fromJson(contactsInput.getString(), Map.class); Set contactObjects = new HashSet(); ArrayList cAddr; -- cgit v1.2.3 From 852fe8974c9bf4fc6da70256233b092c9e8cca7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 24 Nov 2019 21:51:53 +0100 Subject: Improve attribute parsing on submission --- .../mimuw/cloudatlas/client/ClientController.java | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java index 148fb8d..9415888 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java @@ -178,6 +178,17 @@ public class ClientController { return new ValueSet(resultValue, resultValue.iterator().next().getType()); } + private Long parseIntegerAsLong(String value) { + Double doubleVal; + + try { + doubleVal = Double.parseDouble(value); + return doubleVal.longValue(); + } catch (NumberFormatException e) { + return Long.parseLong(value); + } + } + private Value parseAttributeValue(AttributeInput attributeObject) throws Exception { Gson gson = new Gson(); Value attributeValue = null; @@ -197,17 +208,21 @@ public class ClientController { attributeValue = new ValueDouble(Double.parseDouble(attributeObject.getValueString())); break; case "Int": - Double tempDouble = Double.parseDouble(attributeObject.getValueString()); - attributeValue = new ValueInt(tempDouble.longValue()); + attributeValue = new ValueInt(parseIntegerAsLong(attributeObject.getValueString())); break; case "String": attributeValue = new ValueString(attributeObject.getValueString()); break; case "Time": - attributeValue = new ValueTime(Long.parseLong(attributeObject.getValueString())); + attributeValue = new ValueTime(parseIntegerAsLong(attributeObject.getValueString())); break; case "Duration": - attributeValue = new ValueDuration(attributeObject.getValueString()); + if (attributeObject.getValueString().matches("\\d+")) { + attributeValue = new ValueDuration(parseIntegerAsLong(attributeObject.getValueString())); + } else { + String valDuration = attributeObject.getValueString().trim(); + attributeValue = new ValueDuration(valDuration); + } break; case "Contact": DataStringInput contactsString = new DataStringInput(); -- cgit v1.2.3 From 63dfe423c50e9c0f82ccced10b7ca04a30ec4200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 24 Nov 2019 21:55:39 +0100 Subject: Remove duration input as string and fix attribute helper messages --- src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java | 7 +------ .../pl/edu/mimuw/cloudatlas/client/templates/attribForm.html | 5 ++--- .../pl/edu/mimuw/cloudatlas/client/templates/contactsForm.html | 4 ++-- 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src/main') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java index 9415888..4097afe 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java @@ -217,12 +217,7 @@ public class ClientController { attributeValue = new ValueTime(parseIntegerAsLong(attributeObject.getValueString())); break; case "Duration": - if (attributeObject.getValueString().matches("\\d+")) { - attributeValue = new ValueDuration(parseIntegerAsLong(attributeObject.getValueString())); - } else { - String valDuration = attributeObject.getValueString().trim(); - attributeValue = new ValueDuration(valDuration); - } + attributeValue = new ValueDuration(parseIntegerAsLong(attributeObject.getValueString())); break; case "Contact": DataStringInput contactsString = new DataStringInput(); diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html index 3740491..e348a11 100644 --- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html +++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html @@ -47,9 +47,8 @@ Use Json list for complex types and stick to proper format in duration and time.
Examples:
Time: 3600
- Duration (version 1): 3600
- Duration (version 2): +0 00:00:00.001
- Contact: { "contactName" : [ 1, 1, 1, 1 ] }
+ Duration: 3600
+ Contact: { "/contactName" : [ 1, 1, 1, 1 ] }
Query: { "&queryName" : "query" }
List: [ 1, 2, 3 ]
Set: [ [1, 2], [3, 4], [5, 6] ]
diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/contactsForm.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/contactsForm.html index 79a9f5f..ba0a3a8 100644 --- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/contactsForm.html +++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/contactsForm.html @@ -17,8 +17,8 @@ Use Json format for entering contacts. Examples:
- Contact: { "contactName" : [ 1, 1, 1, 1 ] }
- Contact: { "contactName1" : [ 1, 1, 1, 1 ], "contactName2" : [ 2, 2, 2, 2 ] } + Contact: { "/contactName" : [ 1, 1, 1, 1 ] }
+ Contact: { "/contactName1" : [ 1, 1, 1, 1 ], "/contactName2" : [ 2, 2, 2, 2 ] }
-- cgit v1.2.3