Increase data size, make processing more defensive.
LocationBasedServices/mowesta/pipeline/head This commit looks good
LocationBasedServices/mowesta/pipeline/head This commit looks good
This commit is contained in:
@@ -44,6 +44,11 @@ public class MeasurementEntity extends AbstractSpatialEntity {
|
||||
*/
|
||||
private static final long serialVersionUID = 8039668173139778745L;
|
||||
|
||||
/**
|
||||
* The maximum length of the measurement values.
|
||||
*/
|
||||
public static final int VALUE_LENGTH = 200;
|
||||
|
||||
/**
|
||||
* The time stamp when the measurement was taken.
|
||||
*/
|
||||
@@ -69,7 +74,7 @@ public class MeasurementEntity extends AbstractSpatialEntity {
|
||||
@ElementCollection
|
||||
@MapKeyEnumerated(EnumType.ORDINAL)
|
||||
@MapKeyColumn(name="measurement_type")
|
||||
@Column(name="measurement_value", length=32)
|
||||
@Column(name="measurement_value", length=VALUE_LENGTH)
|
||||
@CollectionTable(name="measurement_data", joinColumns=@JoinColumn(name="measurement_id"))
|
||||
private Map<MeasurementType, String> data;
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.mowesta.service.session;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.annotation.security.DeclareRoles;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
import javax.websocket.ClientEndpoint;
|
||||
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.TimeRange;
|
||||
@@ -113,7 +116,30 @@ public class MeasurementSessionBean extends AbstractUserSpecificSessionBean {
|
||||
e.setTemperature(getMeasurementAverage(m, MeasurementType.SENSOR_TEMPERATURE));
|
||||
}
|
||||
if (m.getCoordinate() != null) e.setCoordinate(new EmbeddedCoordinate(m.getCoordinate().getLongitude(), m.getCoordinate().getLatitude()));
|
||||
if (m.getData() != null) e.setData(m.getData());
|
||||
e.setData(new HashMap<>());
|
||||
if (m.getData() != null) {
|
||||
for (Map.Entry<MeasurementType, String> entry: m.getData().entrySet()) {
|
||||
if (entry.getKey() != null) {
|
||||
Object[] values = entry.getKey().getValues(entry.getValue());
|
||||
if (values.length > 0) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
int remaining = MeasurementEntity.VALUE_LENGTH;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
String value = "" + values[i];
|
||||
if (i != 0) value = "," + values[i];
|
||||
int length = value.length();
|
||||
if (remaining - length > 0) {
|
||||
b.append(value);
|
||||
remaining -= length;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
e.getData().put(entry.getKey(), b.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user