public TProperty apply(OEntity input) { return input.getProperty(propName, propClass).getValue(); } };
@Override public boolean apply(OEntity input) { Object pv = input.getProperty(propName).getValue(); return (value == null) ? pv == null : value.equals(pv); } };
public TProperty apply(OEntity input) { return input.getProperty(propName, propClass).getValue(); } };
@Override public boolean apply(OEntity input) { Object pv = input.getProperty(propName).getValue(); return (value == null) ? pv == null : value.equals(pv); } };
@Override public boolean apply(OEntity input) { Object pv = input.getProperty(propName).getValue(); return (value == null) ? pv == null : value.equals(pv); } };
public TProperty apply(OEntity input) { return input.getProperty(propName, propClass).getValue(); } };
private void run(String[] args) { String[] dallasCreds = args.length > 0 ? args : System.getenv("DALLAS").split(":"); ODataConsumer c = ODataConsumers.newBuilder(ODataEndpoints.DALLAS_CTP2_UNESCO_UIS) .setClientBehaviors(OClientBehaviors.basicAuth("accountKey", dallasCreds[0])) .build(); // Public expenditure on education as % of GDP [XGDP_FSGOV] for (OEntity entity : c.getEntities("UNESCO/XGDP_FSGOV").execute() .orderBy(OFuncs.entityPropertyValue("observationValue", Double.class))) // client-side ordering, server-side ordering not supported on dallas report("Public expenditure on education as pct of GDP: %s %s, %.4f", entity.getProperty("referenceArea").getValue(), entity.getProperty("timePeriod").getValue(), entity.getProperty("observationValue").getValue()); // Number of national feature films produced [C_F_220006] for (OEntity entity : c.getEntities("UNESCO/C_F_220006").execute() .orderBy(OFuncs.entityPropertyValue("observationValue", Double.class))) report("Number of national feature films produced: %s %s, %.0f", entity.getProperty("referenceArea").getValue(), entity.getProperty("timePeriod").getValue(), entity.getProperty("observationValue").getValue()); }
private void run(String[] args) { String[] datamarketCreds = args.length > 0 ? args : System.getenv("DATAMARKET").split(":"); String url = "https://api.datamarket.azure.com/Data.ashx/UnitedNations/MDG/"; ODataConsumer c = ODataConsumers.newBuilder(url) .setClientBehaviors(OClientBehaviors.basicAuth("accountKey", datamarketCreds[0])) .build(); OEntity firstDataSeries = c.getEntities("DataSeries").top(1).execute().first(); String filter = String.format("DataSeriesId eq '%s'", firstDataSeries.getProperty("Id").getValue()); reportEntities(firstDataSeries.getProperty("Name", String.class).getValue(), c.getEntities("Values").filter(filter).top(10).execute()); }
public static String create(List<OrderByExpression> orderByList, OEntity lastEntity) { // skip token = <orderbyvalue1,orderbyvalue2,>keystringwithoutparens List<String> values = new LinkedList<String>(); if (orderByList != null) { for (OrderByExpression orderBy : orderByList) { String orderByPropName = ((EntitySimpleProperty) orderBy.getExpression()).getPropertyName(); Object orderByPropValue = lastEntity.getProperty(orderByPropName).getValue(); String valueFilterString = Expression.asFilterString(Expression.literal(orderByPropValue)); values.add(valueFilterString); } } values.add(lastEntity.getEntityKey().toKeyStringWithoutParentheses()); return Enumerable.create(values).join(","); }
isComplex = false; Object value = entity.getProperty(colName).getValue(); if (isComplex) { List<OProperty<?>> embeddedProperties = (List<OProperty<?>>)value;
public static String create(List<OrderByExpression> orderByList, OEntity lastEntity) { // skip token = <orderbyvalue1,orderbyvalue2,>keystringwithoutparens List<String> values = new LinkedList<String>(); if (orderByList != null) { for (OrderByExpression orderBy : orderByList) { String orderByPropName = ((EntitySimpleProperty) orderBy.getExpression()).getPropertyName(); Object orderByPropValue = lastEntity.getProperty(orderByPropName).getValue(); String valueFilterString = Expression.asFilterString(Expression.literal(orderByPropValue)); values.add(valueFilterString); } } values.add(lastEntity.getEntityKey().toKeyStringWithoutParentheses()); return Enumerable.create(values).join(","); }
private void addAutoGeneretedKeys() { OEntity entity = this.response.getResultsIter().next().getEntity(); Table table = this.visitor.getEnityTable(); int cols = table.getPrimaryKey().getColumns().size(); Class<?>[] columnDataTypes = new Class<?>[cols]; String[] columnNames = new String[cols]; //this is typically expected to be an int/long, but we'll be general here. we may eventual need the type logic off of the metadata importer for (int i = 0; i < cols; i++) { columnDataTypes[i] = table.getPrimaryKey().getColumns().get(i).getJavaType(); columnNames[i] = table.getPrimaryKey().getColumns().get(i).getName(); } GeneratedKeys generatedKeys = this.executionContext.getCommandContext().returnGeneratedKeys(columnNames, columnDataTypes); List<Object> vals = new ArrayList<Object>(columnDataTypes.length); for (int i = 0; i < columnDataTypes.length; i++) { OProperty<?> prop = entity.getProperty(columnNames[i]); Object value = this.translator.retrieveValue(prop.getValue(), columnDataTypes[i]); vals.add(value); } generatedKeys.addKey(vals); } }
private void run(String[] args) { ODataConsumer c = ODataConsumers.create(ODataEndpoints.EBAY); OEntity firstDeal = c.getEntities("Deals").top(1).execute().first(); reportEntity(firstDeal.getProperty("Title").getValue().toString(), c.getEntity(firstDeal.getLink("Item", ORelatedEntityLink.class)) .execute()); }
private void run(String[] args) { ODataConsumer.dump.requestHeaders(true); String[] codeplexCreds = args.length > 0 ? args : System.getenv("CODEPLEX").split(":"); String codeplexUser = "snd\\" + codeplexCreds[0] + "_cp"; String codeplexPassword = codeplexCreds[1]; for (String collection : Enumerable.create("TFS03", "TFS05", "TFS09")) { ODataConsumer c = ODataConsumers.newBuilder("https://codeplexodata.cloudapp.net/" + collection) .setClientBehaviors(OClientBehaviors.basicAuth(codeplexUser, codeplexPassword)) .build(); for (OEntity p : c.getEntities("Projects").execute()) { reportEntity("project:", p); if (p.getProperty("Name", String.class).getValue().equals("s3")) continue; for (OEntity cs : listChildren(c, p, "Changesets")) { reportEntity("changeset:", cs); for (OEntity ch : listChildren(c, cs, "Changes")) { reportEntity("change:", ch); } } for (OEntity wi : listChildren(c, p, "WorkItems")) { reportEntity("workitem:", wi); for (OEntity a : listChildren(c, wi, "Attachments")) { reportEntity("attachment:", a); } } } } }
private void run(String[] args) { ODataConsumer c = ODataConsumers.create(ODataEndpoints.NETFLIX); // locate the netflix id for Morgan Spurlock int morganSpurlockId = c.getEntities("People").filter("substringof('Spurlock',Name)").execute().first().getProperty("Id", Integer.class).getValue(); // lookup and print all titles he's acted in List<OEntity> titlesActedIn = c.getEntities("People").nav(morganSpurlockId, "TitlesActedIn").execute().toList(); for (OEntity title : titlesActedIn) { for (OProperty<?> p : title.getProperties()) { report("%s: %s", p.getName(), p.getValue()); } report("\n"); } report("count: " + titlesActedIn.size()); }
private void run(String[] args) { String uri = ODataEndpoints.NORTHWIND; ODataConsumer c = ODataConsumers.create("http://services.odata.org/validation/odatavalidator/"); Guid validationJobId = Guid.fromString("f4aa9495-ef40-469e-818c-29c4ec5fb2ed"); if (true) { OEntity newValidationJob = c.createEntity("ValidationJobs").properties(OProperties.string("Uri", uri), OProperties.string("Format", "atompub")).execute(); reportEntity("new job", newValidationJob); validationJobId = (Guid) newValidationJob.getEntityKey().asSingleValue(); } boolean complete = false; OEntity validationJob = null; while (!complete) { if (validationJob != null) InternalUtil.sleep(500); validationJob = c.getEntity("ValidationJobs", validationJobId).execute(); complete = validationJob.getProperty("Complete", Boolean.class).getValue(); } reportEntity("job", validationJob); for (OEntity testResult : c.getEntities(validationJob.getLink("TestResults", ORelatedEntitiesLink.class)).execute()) { reportEntity("result", testResult); } report("PayloadLines:"); for (OEntity payloadLine : c.getEntities(validationJob.getLink("PayloadLines", ORelatedEntitiesLink.class)).orderBy("LineNumber").execute()) report(payloadLine.getProperty("LineText", String.class).getValue()); }
reportEntity("Product: " + product.getProperty("Name").getValue(), product); .execute(); report("newProduct rating after update: " + c.getEntity("Products", 10).execute().getProperty("Rating").getValue()); .execute(); report("newProduct rating after merge: " + c.getEntity("Products", 10).execute().getProperty("Rating").getValue());
c.mergeEntity("Categories", newCategory.getProperty("id")) .properties(OProperties.string("description", "Merged")) .execute();