public ClientEntityImpl(final FullQualifiedName typeName) { super(typeName == null ? null : typeName.toString()); this.typeName = typeName; }
public ClientEntityImpl(final FullQualifiedName typeName) { super(typeName == null ? null : typeName.toString()); this.typeName = typeName; }
/** * Set the edm entity type. * @param type the edm entity type * @return Builder */ public Builder type(final EdmType type) { contextURL.entitySetOrSingletonOrType = type.getFullQualifiedName().toString(); return this; }
/** * Set the edm entity type. * @param type the edm entity type * @return Builder */ public Builder type(final EdmType type) { contextURL.entitySetOrSingletonOrType = type.getFullQualifiedName().toString(); return this; }
@Override public String getTypeName() { return typeKind.getFullQualifiedName().toString(); }
@Override public String getTypeName() { return typeKind.getFullQualifiedName().toString(); }
@Override public CsdlTerm getTerm(FullQualifiedName fqn) throws ODataException { CsdlTerm term = super.getTerm(fqn); if (term == null) { throw new TeiidRuntimeException(fqn.toString() + " unknown term"); //$NON-NLS-1$ } return term; } }
public static void addAnnotations( final EdmEnabledODataClient client, final Map<Class<? extends AbstractTerm>, Object> annotations, final ClientAnnotatable annotatable) { for (Map.Entry<Class<? extends AbstractTerm>, Object> entry : annotations.entrySet()) { final Namespace nsAnn = entry.getKey().getAnnotation(Namespace.class); final Term termAnn = entry.getKey().getAnnotation(Term.class); final FullQualifiedName termName = new FullQualifiedName(nsAnn.value(), termAnn.name()); final EdmTerm term = client.getCachedEdm().getTerm(termName); if (term == null) { LOG.error("Could not find term for class {}", entry.getKey().getName()); } else { annotatable.getAnnotations().add(getODataAnnotation( client, term.getFullQualifiedName().toString(), term.getType(), entry.getValue())); } } }
@SuppressWarnings("unchecked") public <S extends T, SEC extends EntityCollection<S, ?, ?>> SEC execute(final Class<SEC> collTypeRef) { final Class<S> ref = (Class<S>) ClassUtils.extractTypeArg(collTypeRef, AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class); final Class<S> oref = (Class<S>) ClassUtils.extractTypeArg(collItemRef, AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class); if (!oref.equals(ref)) { uri.appendDerivedEntityTypeSegment(new FullQualifiedName( ClassUtils.getNamespace(ref), ClassUtils.getEntityTypeName(ref)).toString()); } final EntityCollectionInvocationHandler<S> entityCollectionHandler = new EntityCollectionInvocationHandler<S>( service, (Collection<S>) items, collTypeRef, baseURI, uri); return (SEC) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class<?>[] { collTypeRef }, entityCollectionHandler); }
private static Pair<ClientComplexValue, Class<?>> init( final Class<?> typeRef, final AbstractService<?> service) { final Class<?> complexTypeRef; if (Collection.class.isAssignableFrom(typeRef)) { complexTypeRef = ClassUtils.extractTypeArg(typeRef); } else { complexTypeRef = typeRef; } final ComplexType annotation = complexTypeRef.getAnnotation(ComplexType.class); if (annotation == null) { throw new IllegalArgumentException("Invalid complex type " + complexTypeRef); } final FullQualifiedName typeName = new FullQualifiedName(ClassUtils.getNamespace(complexTypeRef), annotation.name()); final ClientComplexValue complex = service.getClient().getObjectFactory().newComplexValue(typeName.toString()); return new ImmutablePair<ClientComplexValue, Class<?>>(complex, complexTypeRef); }
@SuppressWarnings("unchecked") public <S extends T, SEC extends EntityCollection<S, ?, ?>> SEC execute(final Class<SEC> collTypeRef) { final Class<S> ref = (Class<S>) ClassUtils.extractTypeArg(collTypeRef, AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class); final Class<S> oref = (Class<S>) ClassUtils.extractTypeArg(collItemRef, AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class); if (!oref.equals(ref)) { uri.appendDerivedEntityTypeSegment(new FullQualifiedName( ClassUtils.getNamespace(ref), ClassUtils.getEntityTypeName(ref)).toString()); } final EntityCollectionInvocationHandler<S> entityCollectionHandler = new EntityCollectionInvocationHandler<S>( service, (Collection<S>) items, collTypeRef, baseURI, uri); return (SEC) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class<?>[] { collTypeRef }, entityCollectionHandler); }
@Override public EC getResult() { final URIBuilder uriBuilder = client.newURIBuilder(this.baseURI.toASCIIString()). appendDerivedEntityTypeSegment(new FullQualifiedName( ClassUtils.getNamespace(typeRef), ClassUtils.getEntityTypeName(typeRef)).toString()); if (StringUtils.isNotBlank(search)) { uriBuilder.search(search); } return handler.fetchWholeEntitySet(uriBuilder, typeRef, collTypeRef); } }
@Override public EC getResult() { final URIBuilder uriBuilder = client.newURIBuilder(this.baseURI.toASCIIString()). appendDerivedEntityTypeSegment(new FullQualifiedName( ClassUtils.getNamespace(typeRef), ClassUtils.getEntityTypeName(typeRef)).toString()); if (StringUtils.isNotBlank(search)) { uriBuilder.search(search); } return handler.fetchWholeEntitySet(uriBuilder, typeRef, collTypeRef); } }
private EdmTypeInfo buildTypeInfo(final FullQualifiedName typeName, final String propertyType) { EdmTypeInfo typeInfo = null; if (typeName == null) { if (propertyType != null) { typeInfo = new EdmTypeInfo.Builder().setTypeExpression(propertyType).build(); } } else { if (propertyType == null || propertyType.equals(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString())) { typeInfo = new EdmTypeInfo.Builder().setTypeExpression(typeName.toString()).build(); } else if(isPrimiteveType(typeName)) { // Inheritance is not allowed for primitive types, so we use the type given by the EDM. typeInfo = new EdmTypeInfo.Builder().setTypeExpression(typeName.toString()).build(); } else { typeInfo = new EdmTypeInfo.Builder().setTypeExpression(propertyType).build(); } } return typeInfo; }
@Override @SuppressWarnings("unchecked") public <RES extends ClientInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest( final URI bindingParameterURI, final FullQualifiedName actionName, final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection, final Map<String, ClientValue> parameters) { final EdmAction action = edmClient.getCachedEdm().getBoundAction( actionName, bindingParameterTypeName, isBindingParameterCollection); if (action == null) { throw new IllegalArgumentException("Could not find Action for name " + actionName); } return (ODataInvokeRequest<RES>) getInvokeRequest(HttpMethod.POST, edmClient.newURIBuilder(bindingParameterURI.toASCIIString()). appendOperationCallSegment(action.getFullQualifiedName().toString()).build(), getResultReference(action.getReturnType()), parameters); } }
private static ClientProperty getODataProperty( final EdmEnabledODataClient client, final EdmElement edmProperty, final String property, final Object obj) { final EdmTypeInfo type; if (edmProperty == null) { // maybe opentype ... type = null; } else { final EdmType edmType = edmProperty.getType(); type = new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression( edmProperty.isCollection() ? "Collection(" + edmType.getFullQualifiedName().toString() + ")" : edmType.getFullQualifiedName().toString()).build(); } return getODataProperty(client, property, type, obj); }
public static ClientAnnotation getODataAnnotation( final EdmEnabledODataClient client, final String term, final EdmType type, final Object obj) { ClientAnnotation annotation; if (obj == null) { annotation = new ClientAnnotationImpl(term, null); } else { final EdmTypeInfo valueType = type == null ? guessTypeFromObject(client, obj) : new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()). setTypeExpression(type.getFullQualifiedName().toString()).build(); annotation = new ClientAnnotationImpl(term, getODataValue(client, valueType, obj)); } return annotation; }
public static ClientAnnotation getODataAnnotation( final EdmEnabledODataClient client, final String term, final EdmType type, final Object obj) { ClientAnnotation annotation; if (obj == null) { annotation = new ClientAnnotationImpl(term, null); } else { final EdmTypeInfo valueType = type == null ? guessTypeFromObject(client, obj) : new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()). setTypeExpression(type.getFullQualifiedName().toString()).build(); annotation = new ClientAnnotationImpl(term, getODataValue(client, valueType, obj)); } return annotation; }