Search in sources :

Example 1 with DataSources

use of com.infiniteautomation.mango.db.tables.DataSources in project ma-core-public by infiniteautomation.

the class Upgrade44 method upgrade.

@Override
protected void upgrade() throws Exception {
    DataSources table = DataSources.DATA_SOURCES;
    create.createIndex("dataSourcesIdNameTypeXidIndex").on(table, table.id.asc(), table.name.asc(), table.dataSourceType.asc(), table.xid.asc()).execute();
}
Also used : DataSources(com.infiniteautomation.mango.db.tables.DataSources)

Example 2 with DataSources

use of com.infiniteautomation.mango.db.tables.DataSources in project ma-core-public by infiniteautomation.

the class PointValueDaoSQL method topPointHistoryCounts.

@Override
public List<PointHistoryCount> topPointHistoryCounts(int limit) {
    PointValueDao.validateLimit(limit);
    DataPoints points = DataPoints.DATA_POINTS;
    DataSources dataSources = DataSources.DATA_SOURCES;
    Field<Integer> count = DSL.count().as("count");
    return create.select(count).select(dataPointDao.getSelectFields()).from(pv).innerJoin(points).on(points.id.eq(pv.dataPointId)).leftJoin(dataSources).on(dataSources.id.eq(points.dataSourceId)).groupBy(points.id, dataSources.name, dataSources.xid, dataSources.dataSourceType).orderBy(count.desc()).limit(limit).fetch(record -> {
        DataPointVO point = dataPointDao.mapRecord(record);
        dataPointDao.loadRelationalData(point);
        return new PointHistoryCount(point, record.get(count));
    });
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) PointHistoryCount(com.serotonin.m2m2.vo.bean.PointHistoryCount) DataSources(com.infiniteautomation.mango.db.tables.DataSources) DataPoints(com.infiniteautomation.mango.db.tables.DataPoints)

Example 3 with DataSources

use of com.infiniteautomation.mango.db.tables.DataSources in project ma-core-public by infiniteautomation.

the class DataPointDao method createFieldMap.

@Override
protected Map<String, Field<?>> createFieldMap() {
    Map<String, Field<?>> fields = super.createFieldMap();
    fields.put("dataType", table.dataTypeId);
    DataSources dataSources = DataSources.DATA_SOURCES;
    fields.put("dataSourceName", dataSources.name);
    fields.put("dataSourceXid", dataSources.xid);
    fields.put("dataSourceType", dataSources.dataSourceType);
    return fields;
}
Also used : Field(org.jooq.Field) SortField(org.jooq.SortField) DataSources(com.infiniteautomation.mango.db.tables.DataSources)

Aggregations

DataSources (com.infiniteautomation.mango.db.tables.DataSources)3 DataPoints (com.infiniteautomation.mango.db.tables.DataPoints)1 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)1 PointHistoryCount (com.serotonin.m2m2.vo.bean.PointHistoryCount)1 Field (org.jooq.Field)1 SortField (org.jooq.SortField)1