/** * Create an instance of {@link Condition } * */ public Condition createCondition() { return new Condition(); }
@Override public Object getValueAt(int row, int col) { Condition cond = m_conditions.get(row); if (col == 0) { return cond.getProperty(); } else if (col == 1) { return getNiceName(cond.getOperator().toString()); } else { return cond.getValue(); } }
public void updateModelAndNotify() { // create a Condition given the current values Condition cond = new Condition(); cond.setProperty(s_fieldArray[m_fieldBox.getSelectedIndex()]); cond.setOperator(ComparisonOperator .fromValue(s_operatorActuals[m_operatorBox .getSelectedIndex()])); cond.setValue(m_valueField.getText()); // if rowNum is -1, add it if (m_rowNum == -1) { // if it wasn't there before, add it m_model.getConditions().add(cond); } else { // else replace existing condition m_model.getConditions().set(m_rowNum, cond); } m_model.fireTableDataChanged(); }
FieldSearchQuery.Conditions condi = new FieldSearchQuery.Conditions(); org.fcrepo.server.types.gen.Condition cond = new org.fcrepo.server.types.gen.Condition(); cond.setProperty("pid"); cond.setOperator(ComparisonOperator.fromValue("has")); condi.getCondition().add(cond); org.fcrepo.server.types.gen.ObjectFactory factory =
/** * Convert a local {@link Condition} into a WSDL-style * {@link org.fcrepo.server.types.gen.Condition Condition}. */ public static org.fcrepo.server.types.gen.Condition convertConditionToGenCondition(Condition condition) { String opAbbr = condition.getOperator().getAbbreviation(); ComparisonOperator compOperator; try { compOperator = ComparisonOperator.fromValue(opAbbr); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("unrecognized comparison operator string: '" + opAbbr + "'"); } org.fcrepo.server.types.gen.Condition cond = new org.fcrepo.server.types.gen.Condition(); cond.setProperty(condition.getProperty()); cond.setOperator(compOperator); cond.setValue(condition.getValue()); return cond; }
@Test public void testFindObjects() throws Exception { // Test that a search for pid=demo:5 returns one result; demo:5 String[] resultFields = {"pid"}; java.math.BigInteger maxResults = new java.math.BigInteger("" + 100); FieldSearchQuery query = new FieldSearchQuery(); Conditions conds = new Conditions(); Condition cond = new Condition(); cond.setOperator(ComparisonOperator.EQ); cond.setProperty("pid"); cond.setValue("demo:5"); conds.getCondition().add(cond); ObjectFactory factory = new ObjectFactory(); query.setConditions(factory.createFieldSearchQueryConditions(conds)); FieldSearchResult result = apia.findObjects(TypeUtility.convertStringtoAOS(resultFields), maxResults, query); ResultList resultList = result.getResultList(); List<ObjectFields> fields = resultList.getObjectFields(); assertEquals(1, fields.size()); assertEquals("demo:5", fields.get(0).getPid().getValue()); }
public static List<Condition> convertGenConditionArrayToSearchConditionList(org.fcrepo.server.types.gen.FieldSearchQuery.Conditions genConditions) throws org.fcrepo.server.errors.InvalidOperatorException, org.fcrepo.server.errors.QueryParseException { if (genConditions == null) { return null; } ArrayList<Condition> list = new ArrayList<Condition>(); if (genConditions != null && genConditions.getCondition() != null) { for (org.fcrepo.server.types.gen.Condition c : genConditions .getCondition()) { list.add(new org.fcrepo.server.search.Condition(c.getProperty(), c.getOperator() != null ? c .getOperator() .value() : null, c.getValue())); } } return list; }
/** * Create an instance of {@link Condition } * */ public Condition createCondition() { return new Condition(); }
/** * Get the indicated fields of the indicated object from the repository. */ public static ObjectFields getObjectFields(String pid, String[] fields) throws IOException { FieldSearchQuery query = new FieldSearchQuery(); Condition condition = new Condition(); condition.setProperty("pid"); condition.setOperator(ComparisonOperator.fromValue("eq")); condition.setValue(pid); FieldSearchQuery.Conditions conds = new FieldSearchQuery.Conditions(); conds.getCondition().add(condition); ObjectFactory factory = new ObjectFactory(); query.setConditions(factory.createFieldSearchQueryConditions(conds)); FieldSearchResult result = Administrator.APIA .findObjects(TypeUtility.convertStringtoAOS(fields), new BigInteger("1"), query); ResultList resultList = result.getResultList(); if (resultList == null || resultList.getObjectFields() == null && resultList.getObjectFields().size() == 0) { throw new IOException("Object not found in repository"); } return resultList.getObjectFields().get(0); }
public static List<Condition> convertGenConditionArrayToSearchConditionList(org.fcrepo.server.types.gen.FieldSearchQuery.Conditions genConditions) throws org.fcrepo.server.errors.InvalidOperatorException, org.fcrepo.server.errors.QueryParseException { if (genConditions == null) { return null; } ArrayList<Condition> list = new ArrayList<Condition>(); if (genConditions != null && genConditions.getCondition() != null) { for (org.fcrepo.server.types.gen.Condition c : genConditions .getCondition()) { list.add(new org.fcrepo.server.search.Condition(c.getProperty(), c.getOperator() != null ? c .getOperator() .value() : null, c.getValue())); } } return list; }
Condition c = new Condition(); c.setProperty("pid"); c.setOperator(ComparisonOperator.fromValue("eq")); c.setValue(tri.getAttributeValue("value")); conds.getCondition().add(c); query = new FieldSearchQuery();