use of com.infiniteautomation.mango.db.query.QueryAttribute in project ma-core-public by infiniteautomation.
the class MangoVoRestController method getQueryAttributeModel.
/**
* Get the Table Model
* @return
*/
protected TableModel getQueryAttributeModel() {
TableModel model = this.dao.getTableModel();
// Add in our mappings
Iterator<String> it = this.modelMap.keySet().iterator();
while (it.hasNext()) {
String modelMember = it.next();
String mappedTo = this.modelMap.get(modelMember);
for (QueryAttribute attribute : model.getAttributes()) {
if (attribute.getColumnName().equals(mappedTo)) {
attribute.addAlias(modelMember);
}
}
}
return model;
}
use of com.infiniteautomation.mango.db.query.QueryAttribute in project ma-core-public by infiniteautomation.
the class DataPointDao method getIndexes.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.AbstractBasicDao#getIndexes()
*/
@Override
protected List<Index> getIndexes() {
List<Index> indexes = new ArrayList<Index>();
List<QueryAttribute> columns = new ArrayList<QueryAttribute>();
// Data Source Name Force
columns.add(new QueryAttribute("name", new HashSet<String>(), Types.VARCHAR));
indexes.add(new Index("nameIndex", "ds", columns, "ASC"));
// Data Source xid Force
columns = new ArrayList<QueryAttribute>();
columns.add(new QueryAttribute("xid", new HashSet<String>(), Types.VARCHAR));
indexes.add(new Index("dataSourcesUn1", "ds", columns, "ASC"));
// DeviceNameName Index Force
columns = new ArrayList<QueryAttribute>();
columns.add(new QueryAttribute("deviceName", new HashSet<String>(), Types.VARCHAR));
columns.add(new QueryAttribute("name", new HashSet<String>(), Types.VARCHAR));
indexes.add(new Index("deviceNameNameIndex", "dp", columns, "ASC"));
// xid point name force
columns = new ArrayList<QueryAttribute>();
columns.add(new QueryAttribute("xid", new HashSet<String>(), Types.VARCHAR));
columns.add(new QueryAttribute("name", new HashSet<String>(), Types.VARCHAR));
indexes.add(new Index("xidNameIndex", "dp", columns, "ASC"));
return indexes;
}
use of com.infiniteautomation.mango.db.query.QueryAttribute in project ma-modules-public by infiniteautomation.
the class AbstractMangoVoRestV2Controller method getQueryAttributeModel.
/**
* Get the Table Model
* @return
*/
protected TableModel getQueryAttributeModel() {
TableModel model = this.dao.getTableModel();
// Add in our mappings
Iterator<String> it = this.modelMap.keySet().iterator();
while (it.hasNext()) {
String modelMember = it.next();
String mappedTo = this.modelMap.get(modelMember);
for (QueryAttribute attribute : model.getAttributes()) {
if (attribute.getColumnName().equals(mappedTo)) {
attribute.addAlias(modelMember);
}
}
}
return model;
}
use of com.infiniteautomation.mango.db.query.QueryAttribute in project ma-modules-public by infiniteautomation.
the class UserEventsV2Controller method getTableModel.
@ApiOperation(value = "Get Explaination For Query", notes = "What is Query-able on this model")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Ok"), @ApiResponse(code = 403, message = "User does not have access") })
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/explain-query")
public ResponseEntity<TableModel> getTableModel(HttpServletRequest request) {
Map<String, QueryAttribute> attributeMap = new HashMap<>();
Field[] inherited = EventInstance.class.getFields();
for (Field field : inherited) {
QueryAttribute qa = new QueryAttribute(field.getName(), null, getJdbcTypeCode(field.getGenericType().getTypeName()));
attributeMap.put(field.getName(), qa);
}
Field[] all = EventInstance.class.getDeclaredFields();
for (Field field : all) {
QueryAttribute qa = new QueryAttribute(field.getName(), null, getJdbcTypeCode(field.getGenericType().getTypeName()));
attributeMap.put(field.getName(), qa);
}
return new ResponseEntity<>(new TableModel("EventInstance.class", new ArrayList<>(attributeMap.values())), HttpStatus.OK);
}
use of com.infiniteautomation.mango.db.query.QueryAttribute in project ma-modules-public by infiniteautomation.
the class LoggingRestController method getTableModel.
@ApiOperation(value = "Get Explaination For Query", notes = "What is Query-able on this model")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Ok"), @ApiResponse(code = 403, message = "User does not have access") })
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/explain-query")
public ResponseEntity<TableModel> getTableModel(HttpServletRequest request) {
RestProcessResult<TableModel> result = new RestProcessResult<TableModel>(HttpStatus.OK);
this.checkUser(request, result);
if (result.isOk()) {
TableModel model = new TableModel();
List<QueryAttribute> attributes = new ArrayList<QueryAttribute>();
attributes.add(new QueryAttribute("level", null, Types.VARCHAR));
attributes.add(new QueryAttribute("classname", null, Types.VARCHAR));
attributes.add(new QueryAttribute("method", null, Types.VARCHAR));
attributes.add(new QueryAttribute("time", null, Types.INTEGER));
attributes.add(new QueryAttribute("message", null, Types.VARCHAR));
model.setAttributes(attributes);
result.addRestMessage(getSuccessMessage());
return result.createResponseEntity();
}
return result.createResponseEntity();
}
Aggregations