@Override public EdmType getType() { return edmEntitySet.getEntityType(); }
@Override public EdmEntityType getEntityType() { return edmEntitySet.getEntityType(); }
public static String getServiceName(final UriInfoResource uriInfo) throws ODataApplicationException { EdmEntitySet entitySet= getEdmEntitySet(uriInfo,null); String serviceName=null; if(entitySet!=null && entitySet.getEntityType()!=null) { serviceName = entitySet.getEntityType().getNamespace(); } return serviceName; }
@Override public String buildCanonicalURL(final EdmEntitySet edmEntitySet, final Entity entity) throws SerializerException { return edmEntitySet.getName() + '(' + buildKeyPredicate(edmEntitySet.getEntityType(), entity) + ')'; }
@Override public String buildCanonicalURL(final EdmEntitySet edmEntitySet, final Entity entity) throws SerializerException { return edmEntitySet.getName() + '(' + buildKeyPredicate(edmEntitySet.getEntityType(), entity) + ')'; }
@Override public DataSourceHandler getHandler(ODataRequest oDataRequest, EdmEntitySet entitySet) { try { return new CDSHandler(getConnection(oDataRequest), entitySet.getEntityType().getNamespace()); } catch (ODataApplicationException e) { return null; } }
@Override public void visit(UriResourceEntitySet info) { try { this.context = DocumentNode.build(info.getEntitySet().getEntityType(), info.getKeyPredicates(), this.metadata, this.odata, this.nameGenerator, this.aliasedGroups, getUriInfo(), this.parseService); } catch (TeiidException e) { this.exceptions.add(e); } }
@Override public SerializerResult serialize(final ODataRequest request, final EntityCollection result) throws SerializerException { final EdmEntitySet targetEdmEntitySet = Util.determineTargetEntitySet(uriInfo.getUriResourceParts()); final EdmEntityType entityType = targetEdmEntitySet.getEntityType(); return serialize(result, entityType); }
@Override public EntityCollection readUnSavedActive(UriInfo uriInfo, ODataRequest request, ODataResponse response, EntityCollection activeEntities, DataSourceParams dsParams) throws ODataApplicationException { EntityCollection readAllDraftsWithAdminData=readAllDraftsWithAdminData(uriInfo, request, response, dsParams); List<Entity> unSavedActiveEntities=DraftProcessor.unsavedActiveInstances(EdmHelper.getEdmEntitySet(uriInfo, null).getEntityType(), activeEntities, readAllDraftsWithAdminData); EntityCollection ec=new EntityCollection(); ec.setCount(unSavedActiveEntities.size()); ec.getEntities().addAll(applyPagination(uriInfo, unSavedActiveEntities)); return ec; }
@Override public EntityCollection readCombinedEntries(UriInfo uriInfo, ODataRequest request, ODataResponse response, EntityCollection activeEntities, DataSourceParams dsParams) throws ODataApplicationException { EntityCollection readAllDraftsWithAdminData=readAllDraftsWithAdminData(uriInfo, request, response, dsParams); List<Entity> combinedEntries=DraftProcessor.combinedEntries(EdmHelper.getEdmEntitySet(uriInfo, null).getEntityType(), activeEntities, readAllDraftsWithAdminData); EntityCollection ec=new EntityCollection(); ec.setCount(combinedEntries.size()); ec.getEntities().addAll(applyPagination(uriInfo, combinedEntries)); return ec; }
@Override public EntityCollection readUnchangedActive(UriInfo uriInfo, ODataRequest request, ODataResponse response, EntityCollection activeEntities, DataSourceParams dsParams) throws ODataApplicationException { EntityCollection readAllDraftsWithAdminData=readAllDraftsWithAdminData(uriInfo, request, response, dsParams); List<Entity> unchangedEntities=DraftProcessor.unchangedActiveInstances(EdmHelper.getEdmEntitySet(uriInfo, null).getEntityType(), activeEntities, readAllDraftsWithAdminData); EntityCollection ec=new EntityCollection(); ec.setCount(unchangedEntities.size()); ec.getEntities().addAll(applyPagination(uriInfo, unchangedEntities)); return ec; }
public static String getUUIDkeyPropertyName(EdmEntitySet entSet) { EdmEntityType entType=entSet.getEntityType(); for(EdmKeyPropertyRef refs:entType.getKeyPropertyRefs()) { if(refs.getProperty().getType().getFullQualifiedName().getName().equalsIgnoreCase("Guid")) { return refs.getName(); } } return null; }
@Override public EntityCollection readOwnDrafts(UriInfo uriInfo, ODataRequest request, ODataResponse response,EntityCollection activeEntities,DataSourceParams dsParams) throws ODataApplicationException { String userName = HeaderUtil.getUserName(request); EntityCollection readAllDraftsWithAdminData= readAllDraftsWithAdminData(uriInfo, request, response, dsParams); List<Entity> ownDrafts=DraftProcessor.ownDraftInstances(EdmHelper.getEdmEntitySet(uriInfo, null).getEntityType(), activeEntities, readAllDraftsWithAdminData, userName); EntityCollection ec=new EntityCollection(); ec.getEntities().addAll(ownDrafts); return ec; }
@Override public EntityCollection readLockedByOthersEntries(UriInfo uriInfo, ODataRequest request, ODataResponse response, EntityCollection activeEntities, DataSourceParams dsParams) throws ODataApplicationException { String userName = HeaderUtil.getUserName(request); EntityCollection readAllDraftsWithAdminData=readAllDraftsWithAdminData(uriInfo, request, response, dsParams); List<Entity> lockedByOthersEntries=DraftProcessor.lockedByOtherActiveInstances(EdmHelper.getEdmEntitySet(uriInfo, null).getEntityType(), activeEntities, readAllDraftsWithAdminData,userName); EntityCollection ec=new EntityCollection(); ec.setCount(lockedByOthersEntries.size()); ec.getEntities().addAll(applyPagination(uriInfo, lockedByOthersEntries)); return ec; }
public static DeleteEntityInfo transformToDeleteEntityInfo(UriInfo uriInfo){ DeleteEntityInfo dEinfo=new DeleteEntityInfo(); List<UriResource> uriParts = uriInfo.asUriInfoResource().getUriResourceParts(); UriResource lastUriResourcePart = uriParts.get(uriParts.size() - 1); UriResourceEntitySet uriRN=(UriResourceEntitySet) lastUriResourcePart; EdmEntitySet entitySet = ((UriResourceEntitySet) lastUriResourcePart).getEntitySet(); dEinfo.setEntityName(entitySet.getName()); dEinfo.setParententityName(entitySet.getName()); dEinfo.getColumns().addAll(resolveKeyPredicatesToColumnsUpdate(entitySet.getEntityType(),uriRN.getKeyPredicates())); return dEinfo; }
@Override public void visit(UriResourceEntitySet info) { Table table = DocumentNode.findTable(info.getEntitySet(), this.metadata); EdmEntityType type = info.getEntitySet().getEntityType(); List<UriParameter> keys = info.getKeyPredicates(); this.updateTable = new ScopedTable(table, type, keys); }
private static UriInfoDraftHelperV4 transFormerForDelete(Entity ent,EdmEntityContainer entityContainer,DraftFlow flow) throws ODataApplicationException { String serviceName=entityContainer.getNamespace(); UriInfoDraftHelperV4 _uriT=new UriInfoDraftHelperV4(); //Create the UriInfoForCreate EdmEntitySet entSet=entityContainer.getEntitySet(ent.getType().substring(serviceName.length()+1)); //Recheck what value is being stored here .... UriResourceEntitySetImpl entitySetForDelete = new UriResourceEntitySetImpl(entSet); entitySetForDelete.setKeyPredicates(DraftUtilsV4.extractKeyPredicateRefsEntity(ent, entSet.getEntityType())); //Extract Keys from Entity UriInfo uriInfoForDelete = new UriInfoImpl().addResourcePart(entitySetForDelete); _uriT.setUriInfo(uriInfoForDelete); _uriT.setUriFunction(UriFunction.DELETE); return _uriT; }
private Entity getEntityFromClient() throws DeserializerException { ODataDeserializer deserializer = odata.createDeserializer(getRequestContentType(), getServiceMetaData()); return deserializer.entity(getODataRequest().getBody(), getEntitySet().getEntityType()).getEntity(); }
public static CreateEntityInfo transformToDraftsEntityInfo(UriInfo uriInfo, DeserializerResult payLoad)throws ODataApplicationException{ //We can take assumption that the payload will be empty at this point except for the generated key //2. change table name to reflect underlying table instead of main table //.3.Take decision on what happens to additional data (wether they will be calculated or not) CreateEntityInfo cEinfo=new CreateEntityInfo(); EdmEntitySet entitySet=EdmHelper.getEdmEntitySet(uriInfo, null); cEinfo.setEntityName(entitySet.getName()+DraftUtilsV4.DRAFTS_TABLE_NAME_SUFFIX);// Append Name according to shadow tableNameing cEinfo.setParententityName(entitySet.getName()+DraftUtilsV4.DRAFTS_TABLE_NAME_SUFFIX); cEinfo.setColumns(resolvePropertiesToColumns(entitySet.getEntityType(),payLoad.getEntity())); return cEinfo; }
@Override public void updateEntity(DataRequest request, Entity entity, boolean merge, String entityETag, EntityResponse response) throws ODataLibraryException, ODataApplicationException { if (request.getEntitySet().getEntityType().hasStream()) { selectProcessor(MediaEntityProcessor.class).updateMediaEntity( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(),request.getResponseContentType()); } else { selectProcessor(EntityProcessor.class).updateEntity(request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(), request.getResponseContentType()); } }