use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.
the class DBMapPredictor method getLogicalDataByUid.
public LogicalData getLogicalDataByUid(Long UID, @Nonnull Connection connection) throws SQLException {
LogicalData res = null;
if (res != null) {
return res;
}
try (PreparedStatement ps = connection.prepareStatement("SELECT parentRef, ownerId, datatype, ldName, " + "createDate, modifiedDate, ldLength, contentTypesStr, pdriGroupRef, " + "isSupervised, checksum, lastValidationDate, lockTokenID, lockScope, " + "lockType, lockedByUser, lockDepth, lockTimeout, description, locationPreference, status " + "FROM ldata_table WHERE ldata_table.uid = ?")) {
ps.setLong(1, UID);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
res = new LogicalData();
res.setUid(UID);
res.setParentRef(rs.getLong(1));
res.setOwner(rs.getString(2));
res.setType(rs.getString(3));
res.setName(rs.getString(4));
res.setCreateDate(rs.getTimestamp(5).getTime());
res.setModifiedDate(rs.getTimestamp(6).getTime());
res.setLength(rs.getLong(7));
res.setContentTypesAsString(rs.getString(8));
res.setPdriGroupId(rs.getLong(9));
res.setSupervised(rs.getBoolean(10));
res.setChecksum(rs.getString(11));
res.setLastValidationDate(rs.getLong(12));
res.setLockTokenID(rs.getString(13));
res.setLockScope(rs.getString(14));
res.setLockType(rs.getString(15));
res.setLockedByUser(rs.getString(16));
res.setLockDepth(rs.getString(17));
res.setLockTimeout(rs.getLong(18));
res.setDescription(rs.getString(19));
// res.setDataLocationPreference(rs.getString(20));
res.setStatus(rs.getString(21));
return res;
} else {
return null;
}
}
}
use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.
the class DBMapPredictor method getLogicalDataByPath.
public LogicalData getLogicalDataByPath(Path logicalResourceName, @Nonnull Connection connection) throws SQLException {
LogicalData res = null;
if (res != null) {
return res;
}
try (PreparedStatement preparedStatement = connection.prepareStatement("SELECT uid FROM ldata_table WHERE ldata_table.parentRef = ? AND ldata_table.ldName = ?")) {
long parent = 1;
String[] parts = logicalResourceName.getParts();
if (parts.length == 0) {
parts = new String[] { "" };
}
for (int i = 0; i != parts.length; ++i) {
String p = parts[i];
if (i == (parts.length - 1)) {
try (PreparedStatement preparedStatement1 = connection.prepareStatement("SELECT uid, ownerId, datatype, createDate, modifiedDate, ldLength, " + "contentTypesStr, pdriGroupRef, isSupervised, checksum, lastValidationDate, " + "lockTokenID, lockScope, lockType, lockedByUser, lockDepth, lockTimeout, " + "description, locationPreference, status " + "FROM ldata_table WHERE ldata_table.parentRef = ? AND ldata_table.ldName = ?")) {
preparedStatement1.setLong(1, parent);
preparedStatement1.setString(2, p);
ResultSet rs = preparedStatement1.executeQuery();
if (rs.next()) {
res = new LogicalData();
res.setUid(rs.getLong(1));
res.setParentRef(parent);
res.setOwner(rs.getString(2));
res.setType(rs.getString(3));
res.setName(p);
res.setCreateDate(rs.getTimestamp(4).getTime());
res.setModifiedDate(rs.getTimestamp(5).getTime());
res.setLength(rs.getLong(6));
res.setContentTypesAsString(rs.getString(7));
res.setPdriGroupId(rs.getLong(8));
res.setSupervised(rs.getBoolean(9));
res.setChecksum(rs.getString(10));
res.setLastValidationDate(rs.getLong(11));
res.setLockTokenID(rs.getString(12));
res.setLockScope(rs.getString(13));
res.setLockType(rs.getString(14));
res.setLockedByUser(rs.getString(15));
res.setLockDepth(rs.getString(16));
res.setLockTimeout(rs.getLong(17));
res.setDescription(rs.getString(18));
// res.setDataLocationPreference(rs.getString(19));
res.setStatus(rs.getString(20));
return res;
} else {
return null;
}
}
} else {
preparedStatement.setLong(1, parent);
preparedStatement.setString(2, p);
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
parent = rs.getLong(1);
} else {
return null;
}
}
}
return null;
}
}
use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.
the class RandomPredictor method getRandomLogicalData.
private LogicalData getRandomLogicalData(@Nonnull Connection connection) throws SQLException {
LogicalData res = null;
if (res != null) {
return res;
}
try (PreparedStatement ps = connection.prepareStatement("SELECT uid,parentRef, ownerId, datatype, ldName, " + "createDate, modifiedDate, ldLength, contentTypesStr, pdriGroupRef, " + "isSupervised, checksum, lastValidationDate, lockTokenID, lockScope, " + "lockType, lockedByUser, lockDepth, lockTimeout, description, locationPreference, status " + "FROM ldata_table ORDER BY RAND() LIMIT 1")) {
ResultSet rs = ps.executeQuery();
if (rs.next()) {
res = new LogicalData();
res.setUid(rs.getLong(1));
res.setParentRef(rs.getLong(2));
res.setOwner(rs.getString(3));
res.setType(rs.getString(4));
res.setName(rs.getString(5));
res.setCreateDate(rs.getTimestamp(6).getTime());
res.setModifiedDate(rs.getTimestamp(7).getTime());
res.setLength(rs.getLong(8));
res.setContentTypesAsString(rs.getString(9));
res.setPdriGroupId(rs.getLong(10));
res.setSupervised(rs.getBoolean(11));
res.setChecksum(rs.getString(12));
res.setLastValidationDate(rs.getLong(13));
res.setLockTokenID(rs.getString(14));
res.setLockScope(rs.getString(15));
res.setLockType(rs.getString(16));
res.setLockedByUser(rs.getString(17));
res.setLockDepth(rs.getString(18));
res.setLockTimeout(rs.getLong(19));
res.setDescription(rs.getString(20));
// res.setDataLocationPreference(rs.getString(21));
res.setStatus(rs.getString(22));
return res;
} else {
return null;
}
}
}
use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.
the class JDBCatalogue method setLockScope.
public void setLockScope(Long uid, String lockScope, Connection connection) throws SQLException {
try (PreparedStatement ps = connection.prepareStatement("UPDATE ldata_table SET lockScope = ? WHERE uid = ?")) {
ps.setString(1, lockScope);
ps.setLong(2, uid);
ps.executeUpdate();
}
LogicalData cached = getFromLDataCache(uid, null);
if (cached != null) {
cached.setLockScope(lockScope);
putToLDataCache(cached, null);
}
}
use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.
the class JDBCatalogue method setFileChecksum.
public void setFileChecksum(@Nonnull Long uid, @Nonnull String checksum, @Nonnull Connection connection) throws SQLException {
try (PreparedStatement ps = connection.prepareStatement("UPDATE ldata_table SET checksum = ? WHERE uid = ?")) {
ps.setString(1, checksum);
ps.setLong(2, uid);
ps.executeUpdate();
}
LogicalData cached = getFromLDataCache(uid, null);
if (cached != null) {
cached.setChecksum(checksum);
putToLDataCache(cached, null);
}
}
Aggregations