use of ambit2.db.search.property.ModelTemplates in project ambit-mirror by ideaconsult.
the class PropertyModelResource method createQuery.
@Override
protected IQueryRetrieval<Property> createQuery(Context context, Request request, Response response) throws ResourceException {
Form form = request.getResourceRef().getQueryAsForm();
try {
headless = Boolean.parseBoolean(form.getFirstValue("headless"));
} catch (Exception x) {
headless = false;
}
ModelQueryResults model = new ModelQueryResults();
try {
model.setId(Integer.parseInt(getRequest().getAttributes().get(MLResources.model_resourcekey).toString()));
} catch (Exception x) {
model.setId(-1);
if ("null".equals(getRequest().getAttributes().get(MLResources.model_resourcekey).toString()))
model = null;
else
model.setName(getRequest().getAttributes().get(MLResources.model_resourcekey).toString());
}
ModelTemplates query = new ModelTemplates();
try {
query.setValue(Reference.decode(getRequest().getAttributes().get(resourceKey).toString()));
} catch (Exception x) {
query.setValue(null);
}
query.setFieldname(model);
return query;
}
use of ambit2.db.search.property.ModelTemplates in project ambit-mirror by ideaconsult.
the class ModelResource method readVariables.
protected void readVariables(ModelQueryResults model) throws ResourceException {
ModelTemplates query = new ModelTemplates();
query.setFieldname(model);
QueryTemplateReporter<ModelTemplates> reporter = null;
Connection connection = null;
try {
DBConnection dbc = new DBConnection(getContext());
connection = dbc.getConnection();
query.setValue("dependent");
reporter = new QueryTemplateReporter<ModelTemplates>(model.getDependent());
reporter.setCloseConnection(false);
reporter.setConnection(connection);
// dependent
try {
reporter.process(query);
} catch (BatchProcessingException x) {
if (x.getCause() instanceof NotFoundException) {
// this is ok
} else
throw x;
}
query.setValue("independent");
reporter.setConnection(connection);
reporter.setOutput(model.getPredictors());
try {
reporter.process(query);
} catch (BatchProcessingException x) {
if (x.getCause() instanceof NotFoundException) {
// this is ok
} else
throw x;
}
query.setValue("predicted");
reporter.setConnection(connection);
reporter.setOutput(model.getPredicted());
try {
reporter.process(query);
} catch (BatchProcessingException x) {
if (x.getCause() instanceof NotFoundException) {
// ok, it may change the structure only
} else
throw x;
}
} catch (Exception x) {
getLogger().log(Level.FINE, x.getMessage(), x);
}
try {
reporter.setCloseConnection(true);
} catch (Exception x) {
getLogger().log(Level.WARNING, x.getMessage(), x);
} finally {
try {
reporter.close();
} catch (Exception x) {
}
}
try {
connection.close();
} catch (Exception x) {
}
}
Aggregations