perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6019 - trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/se rvice/measurementArchive/sqlType/fetch
Subject: perfsonar development work
List archive
[pS-dev] [GEANT/SA2/ps-java-services] r6019 - trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/se rvice/measurementArchive/sqlType/fetch
Chronological Thread
- From:
- To:
- Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6019 - trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/se rvice/measurementArchive/sqlType/fetch
- Date: Fri, 5 Oct 2012 10:22:56 +0100 (BST)
Author: nordunet.behrmann
Date: 2012-10-05 10:22:56 +0100 (Fri, 05 Oct 2012)
New Revision: 6019
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/BwctlResponseGenerator.java
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/DiscardsResponseGenerator.java
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/ErrorsResponseGenerator.java
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/GenericResponseGenerator.java
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/IperfResponseGenerator.java
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/L2PathStatusResponseGenerator.java
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/OwampResponseGenerator.java
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/PingResponseGenerator.java
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/ResponseGenerator.java
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/UtilizationResponseGenerator.java
Log:
perfsonar-java-sql-ma: Simplify response generators
The response generators used string comparisons on class names to
distinguish between parameter value types. Using an instanceof check
would have been cleaner, easier and faster, however in all cases
the toString() method actually returns the desired result, thus
completely eliminating the need to distinguish between different
parameter types.
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/BwctlResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/BwctlResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/BwctlResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -2,6 +2,7 @@
import java.util.Collection;
+import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -17,117 +18,78 @@
public class BwctlResponseGenerator extends ResponseGenerator
{
-
-
- // -------------------------------------- constructors
-
-
public BwctlResponseGenerator() throws PerfSONARException
{
-
super();
-
}
-
- // -------------------------------------- public methods
-
-
@Override
- public Data getResponse(List<Map<String,Object>> resultList) throws
Exception
+ public Data getResponse(List<Map<String,Object>> resultList)
{
-
-
Data data = new Data();
-
for (Map<String,Object> resultMap: resultList) {
-
Datum datum = new Datum();
- Collection<String> kCollection = resultMap.keySet();
+ for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String value = entry.getValue().toString();
- for (String column : kCollection) {
-
- Object value = resultMap.get(column);
- String className = value.getClass().getName();
- String strValue = null;
-
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
-
if (column.equals("intervalEnd")) {
- datum.setIntervalEnd(strValue);
+ datum.setIntervalEnd(value);
} else if (column.equals("intervalStart")) {
- datum.setIntervalStart(strValue);
+ datum.setIntervalStart(value);
} else if (column.equals("intervalUnit")) {
- datum.setIntervalUnit(strValue);
+ datum.setIntervalUnit(value);
} else if (column.equals("numBytes")) {
- datum.setNumBytes(strValue);
+ datum.setNumBytes(value);
} else if (column.equals("numBytesUnits")) {
- datum.setNumBytesUnits(strValue);
+ datum.setNumBytesUnits(value);
} else if (column.equals("timeType")) {
- datum.setTimeType(strValue);
+ datum.setTimeType(value);
} else if (column.equals("timeValue")) {
- datum.setTimeValue(strValue);
+ datum.setTimeValue(value);
} else if (column.equals("value")) {
- datum.setValue(strValue);
+ datum.setValue(value);
} else if (column.equals("valueUnits")) {
- datum.setValueUnits(strValue);
+ datum.setValueUnits(value);
} else if (column.equals("tcpAdapterType")) {
- datum.setTcpAdapterType(strValue);
+ datum.setTcpAdapterType(value);
} else if (column.equals("tcpMSSSize")) {
- datum.setTcpMSSSize(strValue);
+ datum.setTcpMSSSize(value);
} else if (column.equals("tcpMSSUnit")) {
- datum.setTcpMSSUnit(strValue);
+ datum.setTcpMSSUnit(value);
} else if (column.equals("tcpMTUUnit")) {
- datum.setTcpMTUUnit(strValue);
+ datum.setTcpMTUUnit(value);
} else if (column.equals("tcpMTUSize")) {
- datum.setTcpMTUSize(strValue);
+ datum.setTcpMTUSize(value);
} else if (column.equals("tcpWindowSize")) {
- datum.setTcpWindowSize(strValue);
+ datum.setTcpWindowSize(value);
} else if (column.equals("tcpWindowUnit")) {
- datum.setTcpWindowUnit(strValue);
+ datum.setTcpWindowUnit(value);
} else if (column.equals("udpBufferSize")) {
- datum.setUdpBufferSize(strValue);
+ datum.setUdpBufferSize(value);
} else if (column.equals("udpBufferUnit")) {
- datum.setUdpBufferUnit(strValue);
+ datum.setUdpBufferUnit(value);
} else if (column.equals("udpJitter")) {
- datum.setUdpJitter(strValue);
+ datum.setUdpJitter(value);
} else if (column.equals("udpJitterUnit")) {
- datum.setUdpJitterUnit(strValue);
+ datum.setUdpJitterUnit(value);
} else if (column.equals("udpPacketLoss")) {
- datum.setUdpPacketLoss(strValue);
+ datum.setUdpPacketLoss(value);
} else if (column.equals("udpPacketLossPercentage")) {
- datum.setUdpPacketLossPercentage(strValue);
+ datum.setUdpPacketLossPercentage(value);
} else if (column.equals("udpPacketSent")) {
- datum.setUdpPacketSent(strValue);
+ datum.setUdpPacketSent(value);
}
}
-
-
}
data.addChild(datum);
-
}
return data;
-
}
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/DiscardsResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/DiscardsResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/DiscardsResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -21,79 +21,39 @@
*/
public class DiscardsResponseGenerator extends ResponseGenerator
{
-
-
- // -------------------------------------- constructors
-
-
public DiscardsResponseGenerator() throws PerfSONARException
{
-
super();
-
}
-
- // -------------------------------------- public methods
-
-
@Override
- public Data getResponse(List<Map<String,Object>> resultList) throws
Exception
+ public Data getResponse(List<Map<String,Object>> resultList)
{
-
-
Data data = new Data();
-
for (Map<String,Object> resultMap : resultList) {
-
Datum datum = new Datum();
- for (String column : resultMap.keySet()) {
+ for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String value = entry.getValue().toString();
- Object value = resultMap.get(column);
- String className = value.getClass().getName();
- String strValue = null;
-
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
-
if (column.equals("value")) {
- datum.setValue(strValue);
+ datum.setValue(value);
} else if (column.equals("valueUnits")) {
- datum.setValueUnits(strValue);
+ datum.setValueUnits(value);
} else if (column.equals("timeValue")) {
- datum.setTimeValue(strValue);
+ datum.setTimeValue(value);
datum.setTimeType("unix");
}
-
- //logger.debug("DiscardsResponseGenerator.getResponse: "
- // + "column: " + column + ", value: " + strValue );
-
}
-
}
data.addChild(datum);
-
}
return data;
-
}
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/ErrorsResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/ErrorsResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/ErrorsResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -21,75 +21,36 @@
*/
public class ErrorsResponseGenerator extends ResponseGenerator
{
-
-
- // -------------------------------------- constructors
-
-
public ErrorsResponseGenerator() throws PerfSONARException
{
-
super();
-
}
-
- // -------------------------------------- public methods
-
-
@Override
- public Data getResponse(List<Map<String,Object>> resultList) throws
Exception
+ public Data getResponse(List<Map<String,Object>> resultList)
{
-
-
Data data = new Data();
-
for (Map<String,Object> resultMap: resultList) {
-
Datum datum = new Datum();
- for (String column : resultMap.keySet()) {
+ for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String value = entry.getValue().toString();
- Object value = resultMap.get(column);
- String className = value.getClass().getName();
- String strValue = null;
-
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
-
if (column.equals("value")) {
- datum.setValue(strValue);
+ datum.setValue(value);
} else if (column.equals("valueUnits")) {
- datum.setValueUnits(strValue);
+ datum.setValueUnits(value);
} else if (column.equals("timeValue")) {
- datum.setTimeValue(strValue);
+ datum.setTimeValue(value);
datum.setTimeType("unix");
}
-
- //logger.debug("ErrorsResponseGenerator.getResponse: "
- // + "column: " + column + ", value: " + strValue );
-
}
-
}
data.addChild(datum);
-
}
return data;
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/GenericResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/GenericResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/GenericResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -21,80 +21,38 @@
*/
public class GenericResponseGenerator extends ResponseGenerator
{
-
-
- // -------------------------------------- constructors
-
-
public GenericResponseGenerator() throws PerfSONARException
{
-
super();
-
}
-
- // -------------------------------------- public methods
-
-
@Override
- public Data getResponse(List<Map<String,Object>> resultList) throws
Exception
+ public Data getResponse(List<Map<String,Object>> resultList)
{
-
-
Data data = new Data();
-
for (Map<String,Object> resultMap : resultList) {
-
Datum datum = new Datum();
- for (String column : resultMap.keySet()) {
+ for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String value = entry.getValue().toString();
- Object value = resultMap.get(column);
- String className = value.getClass().getName();
- String strValue = null;
-
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
-
if (column.equals("value")) {
- datum.setValue(strValue);
+ datum.setValue(value);
} else if (column.equals("valueUnits")) {
- datum.setValueUnits(strValue);
+ datum.setValueUnits(value);
} else if (column.equals("timeValue")) {
- datum.setTimeValue(strValue);
+ datum.setTimeValue(value);
datum.setTimeType("unix");
}
-
- //logger.debug("GenericResponseGenerator.getResponse: "
- // + "column: " + column + ", value: " + strValue );
-
}
-
}
data.addChild(datum);
-
}
return data;
-
}
-
-
-} //GenericResponseGenerator
+}
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/IperfResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/IperfResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/IperfResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -21,89 +21,49 @@
*/
public class IperfResponseGenerator extends ResponseGenerator
{
-
-
- // -------------------------------------- constructors
-
-
public IperfResponseGenerator() throws PerfSONARException
{
-
super();
-
}
-
- // -------------------------------------- public methods
-
-
@Override
- public Data getResponse(List<Map<String,Object>> resultList) throws
Exception
+ public Data getResponse(List<Map<String,Object>> resultList)
{
-
-
Data data = new Data();
-
for (Map<String,Object> resultMap : resultList) {
Datum datum = new Datum();
- for (String column : resultMap.keySet()) {
+ for (Map.Entry<String,Object> entry : resultMap.entrySet()) {
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String value = entry.getValue().toString();
- Object value = resultMap.get(column);
- if (value == null) {
- continue;
- }
- String className = value.getClass().getName();
- String strValue = null;
-
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
if (column.equals("value")) {
- datum.addAttr("value", strValue, null);
+ datum.addAttr("value", value, null);
} else if (column.equals("valueUnits")) {
- datum.addAttr("valueUnits", strValue, null);
+ datum.addAttr("valueUnits", value, null);
} else if (column.equals("numBytes")) {
- datum.addAttr("numBytes", strValue, null);
+ datum.addAttr("numBytes", value, null);
} else if (column.equals("numBytesUnits")) {
- datum.addAttr("numBytesUnits", strValue, null);
+ datum.addAttr("numBytesUnits", value, null);
} else if (column.equals("time")) {
- datum.addAttr("timeValue", strValue, null);
+ datum.addAttr("timeValue", value, null);
datum.addAttr("timeType", "unix", null);
} else if (column.equals("interv")) {
- datum.addAttr("interval", strValue, null);
+ datum.addAttr("interval", value, null);
} else if (column.equals("throughput")) {
- datum.addAttr("throughput", strValue, null);
+ datum.addAttr("throughput", value, null);
} else if (column.equals("jitter")) {
- datum.addAttr("jitter", strValue, null);
+ datum.addAttr("jitter", value, null);
} else if (column.equals("loss")) {
- datum.addAttr("loss", strValue, null);
+ datum.addAttr("loss", value, null);
}
-
- //logger.debug("IperfResponseGenerator.getResponse: "
- // + "column: " + column + ", value: " + strValue );
-
}
-
}
data.addChild(datum);
-
}
return data;
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/L2PathStatusResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/L2PathStatusResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/L2PathStatusResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -25,96 +25,47 @@
*/
public class L2PathStatusResponseGenerator extends ResponseGenerator
{
-
-
- // -------------------------------------- constructors
-
-
public L2PathStatusResponseGenerator() throws PerfSONARException
{
-
super();
-
}
-
- // -------------------------------------- public methods
-
-
@Override
- public Data getResponse(List<Map<String,Object>> resultList) throws
Exception
+ public Data getResponse(List<Map<String,Object>> resultList)
{
-
-
Data data = new Data();
-
for (Map<String,Object> resultMap : resultList) {
-
Datum datum = new Datum();
- for (String column : resultMap.keySet()) {
+ for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String strValue = entry.getValue().toString();
- Object value = resultMap.get(column);
- String className = value.getClass().getName();
- String strValue = null;
-
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
-
if (column.equals("status_oper")) {
-
StateOper stateOper = new StateOper();
stateOper.setStateOper(strValue);
datum.addChild(stateOper);
-
- }
- if (column.equals("status_admin")) {
-
+ } else if (column.equals("status_admin")) {
StateAdmin stateAdmin = new StateAdmin();
stateAdmin.setStateAdmin(strValue);
datum.addChild(stateAdmin);
-
} else if (column.equals("valueUnits")) {
-
} else if (column.equals("timeValue")) {
-
NamespaceSupport support = new NamespaceSupport();
support.declarePrefix(datum.getPrefix(),
datum.getUri());
datum.addAttr("timeValue", strValue, support);
datum.addAttr("timeType", "unix", support);
-
}
-
- //logger.debug("SQLStorageManager.fetch: "
- // + "column: " + column + ", value: " + strValue);
-
}
-
}
data.addChild(datum);
-
}
-
return data;
-
}
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/OwampResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/OwampResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/OwampResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -18,14 +18,9 @@
public class OwampResponseGenerator extends ResponseGenerator
{
-
- // -------------------------------------- constructors
-
public OwampResponseGenerator() throws PerfSONARException
{
-
super();
-
}
/**
@@ -35,18 +30,12 @@
*/
public OwampResponseGenerator(String t)
{
-
super(t);
-
}
-
- // -------------------------------------- public methods
-
@Override
- public Data getResponse(List<Map<String,Object>> resultList) throws
Exception
+ public Data getResponse(List<Map<String,Object>> resultList)
{
-
Data data = new Data();
// This is true when resultList contains data from owamp table and is
@@ -91,135 +80,91 @@
for (Map<String,Object> resultMap : resultList) {
System.out.println("Here 2");
- Collection<String> kCollection = resultMap.keySet();
-
if (owamp) {
Datum datum = new Datum();
- for (String column : kCollection) {
- System.out.println("Here 3");
- Object value = resultMap.get(column);
- String className = value.getClass().getName();
- String strValue = null;
+ for (Map.Entry<String, Object> entry : resultMap.entrySet())
{
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String value = entry.getValue().toString();
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
System.out.println("Here 4");
if (column.equals("seqNum")) {
- datum.setSeqNum(strValue);
+ datum.setSeqNum(value);
} else if (column.equals("sendTime")) {
- datum.setSendTime(strValue);
+ datum.setSendTime(value);
} else if (column.equals("sendSynchronized")) {
- datum.setSendSynchronized(strValue);
+ datum.setSendSynchronized(value);
} else if (column.equals("sendTimeError")) {
- datum.setSendTimeError(strValue);
+ datum.setSendTimeError(value);
} else if (column.equals("receiveTime")) {
- datum.setReceiveTime(strValue);
+ datum.setReceiveTime(value);
} else if (column.equals("receiveSynchronized")) {
- datum.setReceiveSynchronized(strValue);
+ datum.setReceiveSynchronized(value);
} else if (column.equals("receiveTimeError")) {
- datum.setReceiveTimeError(strValue);
+ datum.setReceiveTimeError(value);
} else if (column.equals("ttl")) {
- datum.setTTL(strValue);
+ datum.setTTL(value);
}
// else if (column.equals("timeType"))
// datum.setTimeType(strValue);
// else if (column.equals("timeValue"))
// datum.setTimeValue(strValue);
-
- // logger.debug("SQLStorageManager.fetch: "
- } // + "column: " + column + ", value: " + strValue );
-
+ }
}
data.addChild(datum);
-
} else {
OwampAggregationDatum datum = new OwampAggregationDatum();
- for (String column : kCollection) {
- System.out.println("Here 3");
- Object value = resultMap.get(column);
- String className = value.getClass().getName();
- String strValue = null;
+ for (Map.Entry<String, Object> entry : resultMap.entrySet())
{
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String value = entry.getValue().toString();
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
System.out.println("Here 4");
if (column.equals("sender")) {
- datum.setSender(strValue);
+ datum.setSender(value);
} else if (column.equals("receiver")) {
- datum.setReceiver(strValue);
+ datum.setReceiver(value);
} else if (column.equals("sent")) {
- datum.setSent(strValue);
+ datum.setSent(value);
} else if (column.equals("loss")) {
- datum.setLoss(strValue);
+ datum.setLoss(value);
} else if (column.equals("lostPercent")) {
- datum.setLostPercent(strValue);
+ datum.setLostPercent(value);
} else if (column.equals("duplicates")) {
- datum.setDuplicates(strValue);
+ datum.setDuplicates(value);
} else if (column.equals("minDelay")) {
- datum.setMinDelay(strValue);
+ datum.setMinDelay(value);
} else if (column.equals("medDelay")) {
- datum.setMedDelay(strValue);
+ datum.setMedDelay(value);
} else if (column.equals("maxDelay")) {
- datum.setMaxDelay(strValue);
+ datum.setMaxDelay(value);
} else if (column.equals("error")) {
- datum.setError(strValue);
+ datum.setError(value);
} else if (column.equals("delayUnits")) {
- datum.setDelayUnits(strValue);
+ datum.setDelayUnits(value);
} else if (column.equals("errorUnits")) {
- datum.setErrorUnits(strValue);
+ datum.setErrorUnits(value);
} else if (column.equals("jitter")) {
- datum.setJitter(strValue);
+ datum.setJitter(value);
} else if (column.equals("jitterUnits")) {
- datum.setJitterUnits(strValue);
+ datum.setJitterUnits(value);
} else if (column.equals("hops")) {
- datum.setHops(strValue);
+ datum.setHops(value);
}
// else if (column.equals("timeType"))
// datum.setTimeType(strValue);
// else if (column.equals("timeValue"))
// datum.setTimeValue(strValue);
-
- // logger.debug("SQLStorageManager.fetch: "
- } // + "column: " + column + ", value: " + strValue );
-
+ }
}
data.addChild(datum);
}
-
}
System.out.println("Here 6");
return data;
}
-} // OwampResponseGenerator
+}
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/PingResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/PingResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/PingResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -17,88 +17,48 @@
public class PingResponseGenerator extends ResponseGenerator
{
-
-
- // -------------------------------------- constructors
-
-
public PingResponseGenerator() throws PerfSONARException
{
-
super();
-
}
-
- // -------------------------------------- public methods
-
-
@Override
- public Data getResponse(List<Map<String,Object>> resultList) throws
Exception
+ public Data getResponse(List<Map<String,Object>> resultList)
{
-
-
Data data = new Data();
-
for (Map<String,Object> resultMap : resultList) {
-
Datum datum = new Datum();
- for (String column : resultMap.keySet()) {
+ for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String value = entry.getValue().toString();
- Object value = resultMap.get(column);
- String className = value.getClass().getName();
- String strValue = null;
-
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
-
if (column.equals("numBytes")) {
- datum.setNumBytes(strValue);
+ datum.setNumBytes(value);
} else if (column.equals("numBytesUnits")) {
- datum.setNumBytesUnits(strValue);
+ datum.setNumBytesUnits(value);
} else if (column.equals("seqNum")) {
- datum.setSeqNum(strValue);
+ datum.setSeqNum(value);
} else if (column.equals("value")) {
- datum.setValue(strValue);
+ datum.setValue(value);
} else if (column.equals("valueUnits")) {
- datum.setValueUnits(strValue);
+ datum.setValueUnits(value);
} else if (column.equals("ttl")) {
- datum.setTTL(strValue);
+ datum.setTTL(value);
} else if (column.equals("timeType")) {
- datum.setTimeType(strValue);
+ datum.setTimeType(value);
} else if (column.equals("timeValue")) {
- datum.setTimeValue(strValue);
+ datum.setTimeValue(value);
}
-
- //logger.debug("SQLStorageManager.fetch: "
- // + "column: " + column + ", value: " + strValue );
-
}
-
}
data.addChild(datum);
-
}
return data;
-
}
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/ResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/ResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/ResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -23,36 +23,21 @@
*/
public abstract class ResponseGenerator
{
-
-
- // -------------------------------------- class fields
-
-
protected LoggerComponent logger = null;
-
- // -------------------------------------- constructors
-
-
public ResponseGenerator() throws PerfSONARException
{
-
try {
-
logger = (LoggerComponent)
AuxiliaryComponentManager.
getInstance().
getComponent(ComponentNames.LOGGER);
-
} catch (PerfSONARException e) {
-
throw new PerfSONARException(
"error.common.no_logger",
"ResponseGenerator.constructor: "
- + "Cannot get logger component");
-
+ + "Cannot get logger component", e);
}
-
}
/**
@@ -62,14 +47,7 @@
*/
public ResponseGenerator(String t)
{
-
}
-
- // -------------------------------------- public abstract methods
-
-
- public abstract Data getResponse(List<Map<String,Object>> resultList)
throws Exception;
-
-
-} //ResponseGenerator
+ public abstract Data getResponse(List<Map<String,Object>> resultList);
+}
Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/UtilizationResponseGenerator.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/UtilizationResponseGenerator.java
2012-10-05 09:22:55 UTC (rev 6018)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/fetch/UtilizationResponseGenerator.java
2012-10-05 09:22:56 UTC (rev 6019)
@@ -21,57 +21,24 @@
*/
public class UtilizationResponseGenerator extends ResponseGenerator
{
-
-
- // -------------------------------------- constructors
-
-
public UtilizationResponseGenerator() throws PerfSONARException
{
-
super();
-
}
-
- // -------------------------------------- public methods
-
-
@Override
- public Data getResponse(List<Map<String,Object>> resultList) throws
Exception
+ public Data getResponse(List<Map<String,Object>> resultList)
{
-
-
Data data = new Data();
-
for (Map<String,Object> resultMap : resultList) {
-
Datum datum = new Datum();
- for (String column : resultMap.keySet()) {
+ for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
+ if (entry.getValue() != null) {
+ String column = entry.getKey();
+ String strValue = entry.getValue().toString();
- Object value = resultMap.get(column);
- String className = value.getClass().getName();
- String strValue = null;
-
- if (className.equals("java.lang.Float")) {
- strValue = Float.toString((Float) value);
- }
- if (className.equals("java.lang.Double")) {
- strValue = Double.toString((Double) value);
- } else if (className.equals("java.lang.Integer")) {
- strValue = Integer.toString((Integer) value);
- } else if (className.equals("java.lang.Long")) {
- strValue = Long.toString((Long) value);
- } else if (className.equals("java.lang.Date")) {
- strValue = value.toString();
- } else if (className.equals("java.lang.String")) {
- strValue = (String) value;
- }
-
- if (strValue != null) {
-
if (column.equals("value")) {
datum.setValue(strValue);
} else if (column.equals("valueUnits")) {
@@ -80,21 +47,12 @@
datum.setTimeValue(strValue);
datum.setTimeType("unix");
}
-
- //logger.debug("SQLStorageManager.fetch: "
- // + "column: " + column + ", value: " + strValue );
-
}
-
}
data.addChild(datum);
-
}
return data;
-
}
-
-
-} //UtilizationResponseGenerator
+}
- [pS-dev] [GEANT/SA2/ps-java-services] r6019 - trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/se rvice/measurementArchive/sqlType/fetch, svn-noreply, 10/05/2012
Archive powered by MHonArc 2.6.16.