use of com.serotonin.m2m2.vo.hierarchy.PointHierarchy in project ma-core-public by infiniteautomation.
the class DataPointDao method addFoldersToHeirarchy.
private void addFoldersToHeirarchy(PointHierarchy ph, int parentId, Map<Integer, List<PointFolder>> folders) {
List<PointFolder> folderList = folders.remove(parentId);
if (folderList == null)
return;
for (PointFolder f : folderList) {
ph.addPointFolder(f, parentId);
addFoldersToHeirarchy(ph, f.getId(), folders);
}
}
use of com.serotonin.m2m2.vo.hierarchy.PointHierarchy in project ma-core-public by infiniteautomation.
the class DataPointDao method savePointHierarchy.
public synchronized void savePointHierarchy(final PointFolder root) {
// Assign ids to the folders.
final List<Object> params = new ArrayList<>();
final AtomicInteger folderId = new AtomicInteger(getMaxFolderId(root));
for (PointFolder sf : root.getSubfolders()) assignFolderIds(sf, 0, folderId, params);
cachedPointHierarchy = new PointHierarchy(root);
final ExtendedJdbcTemplate ejt2 = ejt;
getTransactionTemplate().execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
// Dump the hierarchy table.
ejt2.update("DELETE FROM dataPointHierarchy");
// Reset the current point folders values in the points.
ejt2.update("UPDATE dataPoints SET pointFolderId=0");
// Save the point folders.
if (folderId.get() > 0) {
StringBuilder sql = new StringBuilder();
sql.append("INSERT INTO dataPointHierarchy (id, parentId, name) VALUES ");
for (int i = 0; i < params.size() / 3; i++) {
// three fields per folder
if (i > 0)
sql.append(",");
sql.append("(?,?,?)");
}
ejt2.update(sql.toString(), params.toArray(new Object[params.size()]));
}
// Save the folder ids for the points.
savePointsInFolder(root);
PointHierarchyEventDispatcher.firePointHierarchySaved(root);
}
});
}
Aggregations