use of com.infiniteautomation.mango.db.query.TableModel 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.TableModel 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.TableModel 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.TableModel 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