@Nullable @Override public <T> T findById(Object id, Class<T> entityClass) { return findById(id, entityClass, operations.determineCollectionName(entityClass)); }
public T findById(K key) { LOG.debug("Find document of collection [{}] by id [{}]", getCollectionName(), key); return mongoTemplate.findById(key, getDocumentClass()); }
public Author findAuthor(Long id) { return this.mongoTemplate.findById(id, Author.class); }
@Nullable @Override public <T> T findById(Object id, Class<T> entityClass) { return findById(id, entityClass, operations.determineCollectionName(entityClass)); }
@Override public FlowDefinitionElement findById(final String id) { return mongoTemplate.findById(id, FlowDefinitionElement.class, collectionName); }
@SuppressWarnings("unchecked") @Override public T findOne(ID id) { return (T) mongoTemplate.findById(id, clz); }
@Override public Student find(String id) { return this.mongoTemplate.findById(id, Student.class); }
@Override public R getById(String recordId) { logger.debug("executing mongo findById(" + recordId + ")"); R record = (R) mongoTemplate.findById(recordId, Record.class, collectionName); return record; }
private Object get(String collectionName, String key) { MongoContextObject mco = template.findById(key, MongoContextObject.class, collectionName); if (mco != null) { return mco.getObject(); } return null; }
@Override @RequiresServiceRole(roleName="READ") public boolean validateCollectionExists(String collectionId) { ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName); return record != null; }
private void checkElementCollection(String collectionId) { ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName); if (record == null ) { throw new NotFoundException(collectionId); } } protected void reportEvent(String collectionId, String contentId, CollectionDocumentType contentType, boolean wasDeleted) {
@Override public Configuration get(String key) { if(AssertUtils.isEmpty(key)) { throw new IllegalArgumentException("Configuration key cannot be null/empty"); } return this.mongoTemplate.findById(key, Configuration.class); }
@Override public List<Object> loadFromListMap(final String collectionName, final String key) { checkValidCollectionName(collectionName); MongoContextObjectList mco = template.findById(key, MongoContextObjectList.class, collectionName); return mco == null ? new LinkedList<>() : mco.getList(); }
@SuppressWarnings("unchecked") @Override public List<ResourceUserRole> findAllUserRoles(String resourceId) { ResourceRoleElement element = mongoTemplate.findById(resourceId, ResourceRoleElement.class, collectionName); if (element == null || element.getUserRoles() == null) { return Collections.EMPTY_LIST; } return element.getUserRoles(); }
@Override @RequiresServiceRole(roleName="READ") public List<String> getCollectionContentIds(String collectionId) { ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName); List<String> result = new ArrayList<String>(); for (AttachedDocument doc : record.getAttachedDocuments()) { result.add(doc.getDocumentId()); } return result; }
@SuppressWarnings("unchecked") @Override public T doInTransaction(TransactionStatus status) { return merge(getMongoTemplate().findById(id, clazz), mergeMode); } });
@Override @RequiresServiceRole(roleName="READ") public CollectionData fetchCollection(String collectionId) { ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName); if (record == null) { return null; } // TODO Check credentials return convertToCollectionData(record); }
@Override @RequiresServiceRole(roleName="READ") public boolean checkIfContainsElement(String collectionId, String documentId) { ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName); for (AttachedDocument doc : record.getAttachedDocuments()) { if (doc.getDocumentId().equals(documentId)) { return true; } } return false; }
@Override protected void doInTransactionWithoutResult(TransactionStatus status) { merge(getMongoTemplate().findById(entity.getId(), getComponentContract(entity)), EMergeMode.MERGE_CLEAN_EAGER); } });
@Override public String getAttachedContentUserId(String collectionId, String documentId) { ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName); if (record == null) { throw new CollectionServiceException( "Getting document '{}' from collection '{}' failed. Collection doesn't exist.", documentId, collectionId); } for (AttachedDocument doc : record.getAttachedDocuments()) { if (doc.getDocumentId().equals(documentId)) { return doc.getAttachedByUserId(); } } return null; }