use of com.serotonin.db.pair.IntStringPair in project ma-core-public by infiniteautomation.
the class VarNames method contextToString.
public static String contextToString(List<IntStringPair> context) {
DataPointDao dataPointDao = DataPointDao.instance;
StringBuilder sb = new StringBuilder();
boolean first = true;
for (IntStringPair ivp : context) {
DataPointVO dp = dataPointDao.getDataPoint(ivp.getKey(), false);
if (first)
first = false;
else
sb.append(", ");
if (dp == null)
sb.append("?=");
else
sb.append(dp.getExtendedName()).append("=");
sb.append(ivp.getValue());
}
return sb.toString();
}
use of com.serotonin.db.pair.IntStringPair in project ma-core-public by infiniteautomation.
the class ScriptUtils method prepareEngine.
/**
* Prepare the Engine by adding all Global Bindings
* @param engine
*/
public static void prepareEngine(ScriptEngine engine) {
Bindings globalBindings = new SimpleBindings();
// Add constants to the context.
globalBindings.put("SECOND", Common.TimePeriods.SECONDS);
globalBindings.put("MINUTE", Common.TimePeriods.MINUTES);
globalBindings.put("HOUR", Common.TimePeriods.HOURS);
globalBindings.put("DAY", Common.TimePeriods.DAYS);
globalBindings.put("WEEK", Common.TimePeriods.WEEKS);
globalBindings.put("MONTH", Common.TimePeriods.MONTHS);
globalBindings.put("YEAR", Common.TimePeriods.YEARS);
globalBindings.put(POINTS_CONTEXT_KEY, new ArrayList<String>());
for (IntStringPair isp : Common.ROLLUP_CODES.getIdKeys(Common.Rollups.NONE)) globalBindings.put(Common.ROLLUP_CODES.getCode(isp.getKey()), isp.getKey());
// Add in Additional Utilities with Global Scope
globalBindings.put(DateTimeUtility.CONTEXT_KEY, new DateTimeUtility());
globalBindings.put(UnitUtility.CONTEXT_KEY, new UnitUtility());
// Holder for modifying timestamps of meta points, in Engine Scope so it can be modified by all
engine.getBindings(ScriptContext.ENGINE_SCOPE).put(TIMESTAMP_CONTEXT_KEY, null);
engine.setBindings(globalBindings, ScriptContext.GLOBAL_SCOPE);
}
use of com.serotonin.db.pair.IntStringPair in project ma-core-public by infiniteautomation.
the class DataPointDao method getPropertiesMap.
/*
* (non-Javadoc)
*
* @see com.serotonin.m2m2.db.dao.AbstractBasicDao#getPropertiesMap()
*/
@Override
protected Map<String, IntStringPair> getPropertiesMap() {
HashMap<String, IntStringPair> map = new HashMap<String, IntStringPair>();
map.put("dataSourceName", new IntStringPair(Types.VARCHAR, "ds.name"));
map.put("dataSourceTypeName", new IntStringPair(Types.VARCHAR, "ds.dataSourceType"));
map.put("dataSourceXid", new IntStringPair(Types.VARCHAR, "ds.xid"));
map.put("dataSourceEditPermission", new IntStringPair(Types.VARCHAR, "ds.editPermission"));
map.put("templateName", new IntStringPair(Types.VARCHAR, "template.name"));
map.put("templateXid", new IntStringPair(Types.VARCHAR, "template.xid"));
return map;
}
use of com.serotonin.db.pair.IntStringPair in project ma-core-public by infiniteautomation.
the class UserCommentDao method getPropertiesMap.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.AbstractBasicDao#getPropertiesMap()
*/
@Override
protected Map<String, IntStringPair> getPropertiesMap() {
Map<String, IntStringPair> map = new HashMap<String, IntStringPair>();
map.put("username", new IntStringPair(Types.VARCHAR, "u.username"));
map.put("referenceId", new IntStringPair(Types.INTEGER, "typeKey"));
map.put("timestamp", new IntStringPair(Types.BIGINT, "ts"));
return map;
}
use of com.serotonin.db.pair.IntStringPair in project ma-core-public by infiniteautomation.
the class AbstractBasicDao method getQueryColumn.
/**
* @param argument
* @return
*/
public SQLQueryColumn getQueryColumn(String prop) {
boolean mapped = false;
Set<String> properties = this.propertyTypeMap.keySet();
String dbCol = prop;
Integer sqlType;
if (propertiesMap.containsKey(prop)) {
IntStringPair pair = propertiesMap.get(prop);
dbCol = pair.getValue();
sqlType = pair.getKey();
mapped = true;
} else {
sqlType = this.propertyTypeMap.get(dbCol);
}
if (mapped || properties.contains(dbCol)) {
if (mapped)
return new SQLQueryColumn(dbCol, sqlType);
else
return new SQLQueryColumn(this.tablePrefix + dbCol, sqlType);
}
// No Column matches...
throw new ShouldNeverHappenException("No column found for: " + prop);
}
Aggregations