public static ComparisonOperator fromValue(String v) { for (ComparisonOperator c: ComparisonOperator.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); }
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(); }
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; }
@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(); } }
/** * 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; }
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; }
/** * 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 ComparisonOperator fromValue(String v) { for (ComparisonOperator c: ComparisonOperator.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); }
Condition c = new Condition(); c.setProperty("pid"); c.setOperator(ComparisonOperator.fromValue("eq")); c.setValue(tri.getAttributeValue("value")); conds.getCondition().add(c);
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 =