FieldSearchQuery query; FieldSearchQuery.Conditions conds = new FieldSearchQuery.Conditions(); Condition c = new Condition(); c.setProperty("pid"); c.setOperator(ComparisonOperator.fromValue("eq")); c.setValue(tri.getAttributeValue("value")); conds.getCondition().add(c); query = new FieldSearchQuery(); ObjectFactory factory = new ObjectFactory();
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 = new org.fcrepo.server.types.gen.ObjectFactory();
cond[i] = conditions.get(i); FieldSearchQuery.Conditions conds = new FieldSearchQuery.Conditions(); conds.getCondition().addAll(conditions); query.setConditions(factory.createFieldSearchQueryConditions(conds));
/** * 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); }
@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; }
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; }
/** * Convert a local {@link FieldSearchQuery} into a WSDL-style * {@link org.fcrepo.server.types.gen.FieldSearchQuery FieldSearchQuery}. */ public static org.fcrepo.server.types.gen.FieldSearchQuery convertFieldSearchQueryToGenFieldSearchQuery(FieldSearchQuery fsq) { List<org.fcrepo.server.types.gen.Condition> genConditions = fsq.getConditions() == null ? null : convertConditionsListToGenConditionsArray(fsq .getConditions()); org.fcrepo.server.types.gen.FieldSearchQuery query = new org.fcrepo.server.types.gen.FieldSearchQuery(); ObjectFactory factory = new ObjectFactory(); org.fcrepo.server.types.gen.FieldSearchQuery.Conditions conds = new org.fcrepo.server.types.gen.FieldSearchQuery.Conditions(); conds.getCondition().addAll(genConditions); query.setConditions(factory.createFieldSearchQueryConditions(conds)); return query; }
/** * Create an instance of {@link FieldSearchQuery.Conditions } * */ public FieldSearchQuery.Conditions createFieldSearchQueryConditions() { return new FieldSearchQuery.Conditions(); }
/** * Create an instance of {@link FieldSearchQuery.Conditions } * */ public FieldSearchQuery.Conditions createFieldSearchQueryConditions() { return new FieldSearchQuery.Conditions(); }