use of io.milton.http.Request.Method in project lobcder by skoulouzis.
the class LDClustering method getlobStateInstances.
private ArrayList<MyInstance> getlobStateInstances(LogicalData n, Method method) {
ArrayList<MyInstance> inst = new ArrayList<>();
if (method == null) {
for (Request.Method m : Request.Method.values()) {
int index = 0;
MyInstance instance = new MyInstance(metdataAttributes.size());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getUid());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), m.code);
instance.setMethod(m);
String att = n.getChecksum();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
att = n.getContentTypesAsString();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getCreateDate());
// att = n.getDataLocationPreference();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
att = n.getDescription();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getLastValidationDate());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getLength());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getModifiedDate());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), "NON");
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getParentRef());
att = n.getStatus();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getType());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), String.valueOf(n.getSupervised()));
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getOwner());
inst.add(instance);
}
} else {
int index = 0;
MyInstance instance = new MyInstance(metdataAttributes.size());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getUid());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), method.code);
instance.setMethod(method);
String att = n.getChecksum();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
att = n.getContentTypesAsString();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getCreateDate());
// att = n.getDataLocationPreference();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
att = n.getDescription();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getLastValidationDate());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getLength());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getModifiedDate());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), "NON");
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getParentRef());
att = n.getStatus();
instance.setValue((Attribute) metdataAttributes.elementAt(index++), (att != null) ? att : "NON");
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getType());
instance.setValue((Attribute) metdataAttributes.elementAt(index++), String.valueOf(n.getSupervised()));
instance.setValue((Attribute) metdataAttributes.elementAt(index++), n.getOwner());
inst.add(instance);
}
return inst;
}
use of io.milton.http.Request.Method in project lobcder by skoulouzis.
the class LDClustering method getNextResourceState.
private Vertex getNextResourceState(Connection connection, double[] features) throws SQLException {
String query = "SELECT ldataRef, " + "methodName, " + "POW((f1 - ?), 2) + " + "POW((f3 - ?), 2) + " + "POW((f4 - ?), 2) + " + "POW((f5 - ?), 2) + " + "POW((f6 - ?), 2) + " + "POW((f7 - ?), 2)+ " + "POW((f8 - ?), 2)+ " + "POW((f9 - ?), 2)+ " + "POW((f10 - ?), 2)+ " + "POW((f11 - ?), 2)+ " + "POW((f12 - ?), 2)+ " + "POW((f13 - ?), 2)+ " + "POW((f14 - ?), 2)+ " + "POW((f15 - ?), 2)+ " + "POW((f16 - ?), 2)" + "AS dist FROM features_table ORDER BY dist ASC LIMIT ?";
try (PreparedStatement preparedStatement = connection.prepareStatement(query)) {
int index = 0;
for (int i = 0; i < features.length; i++) {
if (i != 1) {
index++;
preparedStatement.setDouble(index, features[i]);
}
}
index++;
preparedStatement.setInt(index, k);
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
String path = getPathforLogicalData(getLogicalDataByUid(rs.getLong(1), connection), connection);
Method rquestMethod;
switch(type) {
case resource:
rquestMethod = null;
break;
default:
rquestMethod = Method.valueOf(rs.getString(2));
break;
}
Vertex state = new Vertex(rquestMethod, path);
Logger.getLogger(LDClustering.class.getName()).log(Level.INFO, "State: {0}", state.getID());
}
}
return null;
}
use of io.milton.http.Request.Method in project lobcder by skoulouzis.
the class LDClustering method addFeatures.
private void addFeatures(Connection connection, MyInstance inst, Long uid) throws SQLException {
boolean exists = false;
try (PreparedStatement ps = connection.prepareStatement("select uid " + "from features_table WHERE methodName = ? AND ldataRef = ?")) {
Method requestMethod = inst.getMethod();
if (requestMethod != null) {
ps.setString(1, requestMethod.code);
} else {
ps.setString(1, null);
}
ps.setLong(2, uid);
ResultSet rs = ps.executeQuery();
exists = rs.next();
}
if (!exists) {
addLobStateFeatures(connection, inst, uid);
// switch (type) {
// case state:
// addLobStateFeatures(connection, inst, uid);
// break;
// case resource:
// addResourceFeatures(connection, inst, uid);
// break;
// case method:
// addMethodFeatures(connection, inst, uid);
// break;
// default:
// addLobStateFeatures(connection, inst, uid);
// break;
// }
}
}
use of io.milton.http.Request.Method in project lobcder by skoulouzis.
the class LDClustering method getMethodInstances.
private ArrayList<MyInstance> getMethodInstances(Method method) {
ArrayList<MyInstance> inst = new ArrayList<>();
if (method == null) {
for (Request.Method m : Request.Method.values()) {
int index = 0;
MyInstance instance = new MyInstance(metdataAttributes.size());
index++;
instance.setValue((Attribute) metdataAttributes.elementAt(index++), m.code);
instance.setMethod(m);
inst.add(instance);
}
} else {
int index = 0;
MyInstance instance = new MyInstance(metdataAttributes.size());
index++;
instance.setValue((Attribute) metdataAttributes.elementAt(index++), method.code);
instance.setMethod(method);
inst.add(instance);
}
return inst;
}
use of io.milton.http.Request.Method in project lobcder by skoulouzis.
the class LDClustering method addMethodFeatures.
private void addMethodFeatures(Connection connection, MyInstance inst, Long uid) throws SQLException {
try (PreparedStatement ps = connection.prepareStatement("INSERT INTO " + "features_table (methodName, ldataRef, f1, f2, f3, f4, f5, " + "f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16) " + "VALUES (?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")) {
Method requestMethod = inst.getMethod();
if (requestMethod != null) {
ps.setString(1, requestMethod.code);
} else {
ps.setString(1, null);
}
ps.setLong(2, uid);
double[] features = inst.toDoubleArray();
ps.setDouble(3, features[1]);
ps.executeUpdate();
connection.commit();
}
}
Aggregations