public List<String> getKeyColumnNames(){ return this.edmEntityType.getKeyPredicateNames(); }
private void addKeyPropertiesToSelected(Set<String> selected, EdmStructuredType type) { if (!selected.isEmpty() && type instanceof EdmEntityType) { List<String> keyNames = ((EdmEntityType) type).getKeyPredicateNames(); for (String key : keyNames) { if (!selected.contains(key)) { selected.add(key); } } } }
private void addKeyPropertiesToSelected(Set<String> selected, EdmStructuredType type) { if (!selected.isEmpty() && type instanceof EdmEntityType) { List<String> keyNames = ((EdmEntityType) type).getKeyPredicateNames(); for (String key : keyNames) { if (!selected.contains(key)) { selected.add(key); } } } }
private void addKeyPropertiesToSelected(Set<String> selected, EdmStructuredType type) { if (!selected.isEmpty() && type instanceof EdmEntityType) { List<String> keyNames = ((EdmEntityType) type).getKeyPredicateNames(); for (String key : keyNames) { if (!selected.contains(key)) { selected.add(key); } } } }
private void addKeyPropertiesToSelected(Set<String> selected, EdmStructuredType type) { if (!selected.isEmpty() && type instanceof EdmEntityType) { List<String> keyNames = ((EdmEntityType) type).getKeyPredicateNames(); for (String key : keyNames) { if (!selected.contains(key)) { selected.add(key); } } } }
@Override public List<String> getKeyPredicateNames() { checkBaseType(); if (keyPredicateNames.isEmpty() && baseType != null) { return entityBaseType.getKeyPredicateNames(); } return Collections.unmodifiableList(keyPredicateNames); }
@Override public List<String> getKeyPredicateNames() { checkBaseType(); if (keyPredicateNames.isEmpty() && baseType != null) { return entityBaseType.getKeyPredicateNames(); } return Collections.unmodifiableList(keyPredicateNames); }
/** * This method validates Edm Entity types. * Looks for correct namespace aliases and correct base types */ private void validateEdmEntityTypes() { for (Map.Entry<FullQualifiedName, EdmEntityType> entityTypes : edmEntityTypesMap.entrySet()) { if (entityTypes.getValue() != null && entityTypes.getKey() != null) { EdmEntityType entityType = entityTypes.getValue(); if (entityType.getBaseType() != null) { FullQualifiedName baseTypeFQName = entityType.getBaseType().getFullQualifiedName(); EdmEntityType baseEntityType = edmEntityTypesMap.get(baseTypeFQName); if (baseEntityType != null && baseEntityType.getKeyPredicateNames().isEmpty()) { throw new RuntimeException("Missing key for EntityType " + baseEntityType.getName()); } } else if (entityType.getKeyPredicateNames().isEmpty()) { throw new RuntimeException("Missing key for EntityType " + entityType.getName()); } } } }
/** * This method validates Edm Entity types. * Looks for correct namespace aliases and correct base types */ private void validateEdmEntityTypes() { for (Map.Entry<FullQualifiedName, EdmEntityType> entityTypes : edmEntityTypesMap.entrySet()) { if (entityTypes.getValue() != null && entityTypes.getKey() != null) { EdmEntityType entityType = entityTypes.getValue(); if (entityType.getBaseType() != null) { FullQualifiedName baseTypeFQName = entityType.getBaseType().getFullQualifiedName(); EdmEntityType baseEntityType = edmEntityTypesMap.get(baseTypeFQName); if (baseEntityType != null && baseEntityType.getKeyPredicateNames().isEmpty()) { throw new RuntimeException("Missing key for EntityType " + baseEntityType.getName()); } } else if (entityType.getKeyPredicateNames().isEmpty()) { throw new RuntimeException("Missing key for EntityType " + entityType.getName()); } } } }
public static List<UriParameter> extractKeyPredicateRefsEntity(Entity ent,EdmEntityType entityType) throws ODataApplicationException { List<UriParameter> keyparams=new ArrayList<>(); for(String key:entityType.getKeyPredicateNames()) { if(!key.equalsIgnoreCase(DraftUtilsV4.DRAFTS_ISACTIVE_ENTITY)) { UriParameter keyparam=new UriParameterImpl().setName(key).setText(ent.getProperty(key).getValue().toString()); keyparams.add(keyparam); } } return keyparams; }
private boolean areKeyPredicateNamesSelected(SelectOption select, EdmEntityType type) { if (select == null || ExpandSelectHelper.isAll(select)) { return true; } final Set<String> selected = ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); for (String key : type.getKeyPredicateNames()) { if (!selected.contains(key)) { return false; } } return true; }
private boolean areKeyPredicateNamesSelected(SelectOption select, EdmEntityType type) { if (select == null || ExpandSelectHelper.isAll(select)) { return true; } final Set<String> selected = ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); for (String key : type.getKeyPredicateNames()) { if (!selected.contains(key)) { return false; } } return true; }
protected void addOrderByForKeyPredicates(ReadEntityInfo eInfo, EdmEntityType entity) { if (entity != null && entity.getKeyPredicateNames() != null) { for (int i = 0; i < entity.getKeyPredicateNames().size(); i++) { String keyName = entity.getKeyPropertyRef(entity.getKeyPredicateNames().get(i)).getName().replace("/", "."); if (!eInfo.getOrderBySeq().contains(keyName) && !keyName.equalsIgnoreCase(DraftUtilsV4.DRAFTS_ISACTIVE_ENTITY)) { eInfo.getOrderBySeq().add(keyName); OrderBy orderBy = new OrderBy(); orderBy.setDescending(false); orderBy.setPropertyName(keyName); Column col = eInfo.getColumnByName(keyName, eInfo.getColumns()); orderBy.setAliasName(col.getDbaliasName()); eInfo.getOrderby().put( entity.getKeyPropertyRef(entity.getKeyPredicateNames().get(i)).getName().replace("/", "."), orderBy); } } } }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @param entityType the entity Type * @param name the entity name * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { if(entity.getId() == null) { if((entity == null || entityType == null || entityType.getKeyPredicateNames() == null || name == null)) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); }else{ final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); } } return entity.getId().toASCIIString(); }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @param entityType * @param name * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { if(entity != null && entity.getId() == null) { if(entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); }else{ final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); } } return entity.getId().toASCIIString(); }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @param entityType * @param name * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { if(entity != null && entity.getId() == null) { if(entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); }else{ final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); } } return entity.getId().toASCIIString(); }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { try { if (entity != null) { if (entity.getId() == null) { if (entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } else { final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); return entity.getId().toASCIIString(); } } else { return entity.getId().toASCIIString(); } } return null; } catch (Exception e) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { try { if (entity != null) { if (entity.getId() == null) { if (entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } else { final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); return entity.getId().toASCIIString(); } } else { return entity.getId().toASCIIString(); } } return null; } catch (Exception e) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } }
public static List<Entity> ownDraftInstances(EdmEntityType entity,EntityCollection activeCollection,EntityCollection draftCollection,String userName) { String keyPropertyName = null; for(String key:entity.getKeyPredicateNames()) { if(!key.equalsIgnoreCase(DraftUtilsV4.DRAFTS_ISACTIVE_ENTITY)) { keyPropertyName=key; } } //Currently dealing only in UUID Map<UUID, Entity> activeInstances=convertEntityCollectiontoMap(keyPropertyName, activeCollection); filterDraftEntityCollectionOnUser(draftCollection, userName); //Iterate over draft instances and identify if there is an active instance for(Entity draftEntity:draftCollection.getEntities()) { if(activeInstances.get(draftEntity.getProperty(keyPropertyName).getValue())!=null) { //If -so correct the HAS_ACTIVE_ENTITY PROPERTY draftEntity.getProperty(DraftUtilsV4.DRAFTS_HASACTIVE_ENTITY).setValue(ValueType.PRIMITIVE, true); } } //return the draftInstances return draftCollection.getEntities(); }
private ODataEntry getKeyPredicatesFromEntity(EdmEntityType entityType, Entity entity) throws ODataApplicationException { ODataEntry keyPredicates = new ODataEntry(); for (String key : entityType.getKeyPredicateNames()) { EdmProperty propertyType = (EdmProperty) entityType.getProperty(key); keyPredicates.addValue(key, readPrimitiveValueInString(propertyType, entity.getProperty(key).getValue())); } return keyPredicates; }