use of com.serotonin.m2m2.DataType in project ma-core-public by infiniteautomation.
the class BaseChartRenderer method getImplementations.
public static List<ImplDefinition> getImplementations(int dataType) {
ensureDefinitions();
List<ImplDefinition> impls = new ArrayList<ImplDefinition>();
for (ImplDefinition def : definitions) {
if (def.supports(dataType))
impls.add(def);
}
return impls;
}
use of com.serotonin.m2m2.DataType in project ma-core-public by infiniteautomation.
the class AbstractPointLocatorVO method readDataType.
protected Integer readDataType(JsonObject json, int... excludeIds) throws JsonException {
String text = json.getString("dataType");
if (text == null)
return null;
int dataType = DataTypes.CODES.getId(text);
if (!DataTypes.CODES.isValidId(dataType, excludeIds))
throw new TranslatableJsonException("emport.error.invalid", "dataType", text, DataTypes.CODES.getCodeList(excludeIds));
return dataType;
}
use of com.serotonin.m2m2.DataType in project ma-core-public by infiniteautomation.
the class BaseTextRenderer method getImplementation.
public static List<ImplDefinition> getImplementation(int dataType) {
ensureDefinitions();
List<ImplDefinition> impls = new ArrayList<ImplDefinition>(definitions.size());
for (ImplDefinition def : definitions) {
if (def.supports(dataType))
impls.add(def);
}
return impls;
}
use of com.serotonin.m2m2.DataType in project ma-core-public by infiniteautomation.
the class DataPointPropertiesTemplateVO method jsonRead.
@Override
public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
// Not reading XID so can't do this: super.jsonRead(reader, jsonObject);
name = jsonObject.getString("name");
// Not reading XID so can't do this: super.jsonRead(reader, jsonObject);
String text = jsonObject.getString("templateType");
if (text != null) {
dataTypeId = TEMPLATE_TYPE_CODES.getId(text);
if (dataTypeId == -1)
throw new TranslatableJsonException("emport.error.invalid", "templateType", text, TEMPLATE_TYPE_CODES.getCodeList());
}
text = jsonObject.getString("dataType");
if (text != null) {
dataTypeId = DataTypes.CODES.getId(text);
if (dataTypeId == -1)
throw new TranslatableJsonException("emport.error.invalid", "dataType", text, DataTypes.CODES.getCodeList());
}
// Rollup
text = jsonObject.getString("rollup");
if (text != null) {
rollup = Common.ROLLUP_CODES.getId(text);
if (rollup == -1)
throw new TranslatableJsonException("emport.error.chart.invalid", "rollup", text, Common.ROLLUP_CODES.getCodeList());
}
text = jsonObject.getString("loggingType");
if (text != null) {
loggingType = DataPointVO.LOGGING_TYPE_CODES.getId(text);
if (loggingType == -1)
throw new TranslatableJsonException("emport.error.invalid", "loggingType", text, DataPointVO.LOGGING_TYPE_CODES.getCodeList());
}
text = jsonObject.getString("intervalLoggingPeriodType");
if (text != null) {
intervalLoggingPeriodType = Common.TIME_PERIOD_CODES.getId(text);
if (intervalLoggingPeriodType == -1)
throw new TranslatableJsonException("emport.error.invalid", "intervalLoggingPeriodType", text, Common.TIME_PERIOD_CODES.getCodeList());
}
text = jsonObject.getString("intervalLoggingType");
if (text != null) {
intervalLoggingType = DataPointVO.INTERVAL_LOGGING_TYPE_CODES.getId(text);
if (intervalLoggingType == -1)
throw new TranslatableJsonException("emport.error.invalid", "intervalLoggingType", text, DataPointVO.INTERVAL_LOGGING_TYPE_CODES.getCodeList());
}
text = jsonObject.getString("purgeType");
if (text != null) {
purgeType = Common.TIME_PERIOD_CODES.getId(text);
if (purgeType == -1)
throw new TranslatableJsonException("emport.error.invalid", "purgeType", text, Common.TIME_PERIOD_CODES.getCodeList());
}
text = jsonObject.getString("plotType");
if (text != null) {
plotType = DataPointVO.PLOT_TYPE_CODES.getId(text);
if (plotType == -1)
throw new TranslatableJsonException("emport.error.invalid", "plotType", text, DataPointVO.PLOT_TYPE_CODES.getCodeList());
}
// Simplify
text = jsonObject.getString("simplifyType");
if (text != null) {
simplifyType = DataPointVO.SIMPLIFY_TYPE_CODES.getId(text);
if (simplifyType == -1)
throw new TranslatableJsonException("emport.error.invalid", "simplifyType", text, DataPointVO.SIMPLIFY_TYPE_CODES.getCodeList());
}
int simplifyTarget = jsonObject.getInt("simplifyTarget", Integer.MIN_VALUE);
if (simplifyTarget != Integer.MIN_VALUE)
this.simplifyTarget = simplifyTarget;
double simplifyTolerance = jsonObject.getDouble("simplifyTolerance", Double.NaN);
if (simplifyTolerance != Double.NaN)
this.simplifyTolerance = simplifyTolerance;
}
use of com.serotonin.m2m2.DataType in project ma-core-public by infiniteautomation.
the class FileUploadController method parseFile.
/**
* Parse the Import Files
* @param input
* @param model
* @param translations
*/
protected void parseFile(InputStream input, Map<String, Object> model, Translations translations, HttpServletRequest request) {
// Get the filename
String filename = (String) model.get("filename");
SpreadsheetEmporter emporter;
if (filename == null)
return;
else {
if (filename.toLowerCase().endsWith(".xls"))
emporter = new SpreadsheetEmporter(FileType.XLS);
else if (filename.toLowerCase().endsWith(".xlsx"))
emporter = new SpreadsheetEmporter(FileType.XLSX);
else
return;
}
// Switch on the type
String dataType = (String) model.get("dataType");
if (dataType != null) {
if (dataType.equals("pointValue")) {
// List the sheets and create sheet emporters for each
for (Sheet sheet : emporter.listSheets(input)) emporter.doImport(input, new PointValueEmporter(sheet.getSheetName()));
} else
throw new ShouldNeverHappenException("Unsupported data.");
}
model.put("hasImportErrors", emporter.hasErrors());
// Get the messages
if (emporter.hasErrors()) {
List<String> errorMessages = new ArrayList<String>();
for (TranslatableMessage msg : emporter.getErrorMessages()) {
errorMessages.add(msg.translate(translations));
}
model.put("errorMessages", errorMessages);
}
model.put("rowsImported", emporter.getRowsAdded());
model.put("rowsDeleted", emporter.getRowsDeleted());
model.put("rowsWithErrors", emporter.getRowErrors());
}
Aggregations