Search in sources :

Example 1 with QLabel

use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.

the class QLabelQueryResource method createQuery.

@Override
protected IQueryRetrieval<IStructureRecord> createQuery(Context context, Request request, Response response) throws ResourceException {
    QueryStructureByQuality q = new QueryStructureByQuality();
    Form form = request.getResourceRef().getQueryAsForm();
    try {
        includeMol = "true".equals(form.getFirstValue("mol"));
    } catch (Exception x) {
        includeMol = false;
    }
    Object key = form.getFirstValue(QueryResource.search_param);
    if (key != null) {
        try {
            q.setValue(new QLabel(QUALITY.valueOf(Reference.decode(key.toString()))));
        } catch (Exception x) {
            StringBuilder b = new StringBuilder();
            b.append("Valid values are ");
            for (QUALITY v : QUALITY.values()) {
                b.append(v);
                b.append('\t');
            }
            throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, b.toString(), x);
        }
    } else {
        q.setValue(new QLabel(QUALITY.OK));
    }
    Object id = request.getAttributes().get(OpenTox.URI.dataset.getKey());
    if (id != null)
        try {
            datasetID = Integer.parseInt(id.toString());
            SourceDataset dataset = new SourceDataset();
            dataset.setId(datasetID);
            q.setFieldname(dataset);
            return q;
        } catch (Exception x) {
            if (id.toString().startsWith("R")) {
                queryResultsID = Integer.parseInt(id.toString().substring(1));
                StoredQuery dataset = new StoredQuery();
                dataset.setId(queryResultsID);
                q.setFieldname(dataset);
                return q;
            } else
                throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Invalid dataset id");
        }
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No dataset !");
}
Also used : StoredQuery(ambit2.db.search.StoredQuery) QUALITY(ambit2.base.data.QLabel.QUALITY) Form(org.restlet.data.Form) QLabel(ambit2.base.data.QLabel) QueryStructureByQuality(ambit2.db.search.structure.QueryStructureByQuality) ResourceException(org.restlet.resource.ResourceException) SourceDataset(ambit2.base.data.SourceDataset) ResourceException(org.restlet.resource.ResourceException)

Example 2 with QLabel

use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.

the class QueryQLabel method getObject.

public QLabel getObject(ResultSet rs) throws AmbitException {
    try {
        QLabel label = new QLabel();
        label.setUser(new AmbitUser(rs.getString(2)));
        label.setLabel(QUALITY.valueOf(rs.getString(3)));
        label.setText(rs.getString(4));
        return label;
    } catch (SQLException x) {
        throw new AmbitException(x);
    }
}
Also used : SQLException(java.sql.SQLException) QLabel(ambit2.base.data.QLabel) AmbitUser(ambit2.base.data.AmbitUser) AmbitException(net.idea.modbcum.i.exceptions.AmbitException)

Example 3 with QLabel

use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.

the class QueryStructurebyQualityTest method verify.

@Override
protected void verify(QueryStructureByQuality query, ResultSet rs) throws Exception {
    while (rs.next()) {
        IStructureRecord record = query.getObject(rs);
        Assert.assertEquals(10, record.getIdchemical());
        Assert.assertEquals(100214, record.getIdstructure());
        Assert.assertEquals(new QLabel(QUALITY.OK), query.retrieveValue(rs));
    }
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) QLabel(ambit2.base.data.QLabel)

Example 4 with QLabel

use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.

the class QueryQLabelTest method verify.

@Override
protected void verify(QueryQLabel query, ResultSet rs) throws Exception {
    while (rs.next()) {
        QLabel q = query.getObject(rs);
        Assert.assertEquals(QUALITY.OK, q.getLabel());
        Assert.assertEquals("guest", q.getUser().getName());
    }
}
Also used : QLabel(ambit2.base.data.QLabel) QueryQLabel(ambit2.db.search.qlabel.QueryQLabel)

Example 5 with QLabel

use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.

the class StructureQLabel_crud_test method createQuery.

@Override
protected IQueryUpdate<IStructureRecord, QLabel> createQuery() throws Exception {
    CreateStructureQLabel q = new CreateStructureQLabel();
    q.setGroup(new StructureRecord(-1, 100211, null, null));
    q.setObject(new QLabel(QUALITY.ProbablyOK));
    return q;
}
Also used : CreateStructureQLabel(ambit2.db.update.qlabel.CreateStructureQLabel) IStructureRecord(ambit2.base.interfaces.IStructureRecord) StructureRecord(ambit2.base.data.StructureRecord) QLabel(ambit2.base.data.QLabel) CreateStructureQLabel(ambit2.db.update.qlabel.CreateStructureQLabel) DeleteStructureQLabel(ambit2.db.update.qlabel.DeleteStructureQLabel)

Aggregations

QLabel (ambit2.base.data.QLabel)17 IStructureRecord (ambit2.base.interfaces.IStructureRecord)5 CreateStructureQLabel (ambit2.db.update.qlabel.CreateStructureQLabel)5 StructureRecord (ambit2.base.data.StructureRecord)4 DeleteStructureQLabel (ambit2.db.update.qlabel.DeleteStructureQLabel)4 AmbitUser (ambit2.base.data.AmbitUser)3 CreateValueQLabel (ambit2.db.update.qlabel.CreateValueQLabel)3 DeleteValueQLabel (ambit2.db.update.qlabel.DeleteValueQLabel)3 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)3 SourceDataset (ambit2.base.data.SourceDataset)2 StoredQuery (ambit2.db.search.StoredQuery)2 QueryQLabel (ambit2.db.search.qlabel.QueryQLabel)2 QueryStructureByQuality (ambit2.db.search.structure.QueryStructureByQuality)2 JComboBox (javax.swing.JComboBox)2 Form (org.restlet.data.Form)2 ResourceException (org.restlet.resource.ResourceException)2 ISourceDataset (ambit2.base.data.ISourceDataset)1 QUALITY (ambit2.base.data.QLabel.QUALITY)1 SQLException (java.sql.SQLException)1 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)1