protected void findSchema(Context c) { EdmDataServices ds = dataProducer.getMetadata(); String nm = (String) c.entityKey.asSingleValue(); for (EdmSchema s : ds.getSchemas()) { if (nm.equals(s.getNamespace())) { c.entities.add(this.getSchema(c, s)); } } }
protected void findSchema(Context c) { EdmDataServices ds = dataProducer.getMetadata(); String nm = (String) c.entityKey.asSingleValue(); for (EdmSchema s : ds.getSchemas()) { if (nm.equals(s.getNamespace())) { c.entities.add(this.getSchema(c, s)); } } }
public boolean apply(Object input) { HashMap<String, Object> idObjectMap = ei.id.apply(input); if (keyList.length == 1) { Object idValue = rc.getEntityKey().asSingleValue(); return idObjectMap.get(keyList[0]).equals(idValue); } else if (keyList.length > 1) { for (String key : keyList) { Object curValue = null; Iterator<OProperty<?>> keyProps = rc.getEntityKey().asComplexProperties().iterator(); while (keyProps.hasNext()) { OProperty<?> keyProp = keyProps.next(); if (keyProp.getName().equalsIgnoreCase(key)) { curValue = keyProp.getValue(); } } if (curValue == null) { return false; } else if (!idObjectMap.get(key).equals(curValue)) { return false; } } return true; } else { return false; } } });
protected BoolCommonExpression prependPrimaryKeyFilter(JdbcMetadataMapping mapping, EdmEntityType entityType, OEntityKey entityKey, BoolCommonExpression filter) { List<BoolCommonExpression> filters = new ArrayList<BoolCommonExpression>(); if (entityType.getKeys().size() == 1) { String key = entityType.getKeys().iterator().next(); filters.add(Expression.eq(Expression.simpleProperty(key), Expression.literal(entityKey.asSingleValue()))); } else { Map<String, NamedValue<?>> complexKey = Enumerable.create(entityKey.asComplexValue()).toMap(new Func1<NamedValue<?>, String>() { @Override public String apply(NamedValue<?> nv) { return nv.getName(); } }); for (String key : entityType.getKeys()) { filters.add(Expression.eq(Expression.simpleProperty(key), Expression.literal(complexKey.get(key).getValue()))); } } if (filter != null) filters.add(filter); BoolCommonExpression newFilter = null; for (BoolCommonExpression f : filters) newFilter = newFilter == null ? f : Expression.and(f, newFilter); return newFilter; }
if (entityKey.getKeyType() == KeyType.SINGLE) { LiteralExpression entityKeyValue = Expression.literal(entityKey.asSingleValue());
LiteralExpression entityKeyValue = Expression.literal(entityKey.asSingleValue());
static Object typeSafeEntityKey( EntityManager em, EntityType<?> jpaEntityType, OEntityKey entityKey) { if (entityKey != null && jpaEntityType.getIdType().getPersistenceType() == PersistenceType.EMBEDDABLE) { Object id = newInstance(jpaEntityType.getIdType().getJavaType()); applyOProperties( em, em.getMetamodel().embeddable( jpaEntityType.getIdType().getJavaType()), entityKey.asComplexProperties(), id); return id; } Class<?> javaType = jpaEntityType.getIdType().getJavaType(); try { return TypeConverter.convert(entityKey == null ? null : entityKey.asSingleValue(), javaType); } catch (UnsupportedOperationException e) { throw new BadRequestException("Invalid key type", e); } catch (IllegalArgumentException e) { throw new BadRequestException("Invalid key value", e); } }
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()); }