Package com.baasbox.dao

Examples of com.baasbox.dao.DocumentDao


  public static final String FIELD_LINKS = NodeDao.FIELD_LINK_TO_VERTEX;
  private static final String OBJECT_QUERY_ALIAS = "result";

  public static ODocument create(String collection, JsonNode bodyJson) throws Throwable, InvalidCollectionException,InvalidModelException {
    DocumentDao dao = DocumentDao.getInstance(collection);
    DbHelper.requestTransaction();

    ODocument doc = dao.create();
    try  {
      dao.update(doc,(ODocument) (new ODocument()).fromJSON(bodyJson.toString()));
      dao.save(doc);
      DbHelper.commitTransaction();
    }catch (OSerializationException e){
      DbHelper.rollbackTransaction();
      throw new InvalidJsonException(e);
    }catch (UpdateOldVersionException e){
View Full Code Here


   */
  public static ODocument update(String collectionName,String rid, JsonNode bodyJson) throws InvalidCollectionException,InvalidModelException, ODatabaseException, IllegalArgumentException, DocumentNotFoundException, UpdateOldVersionException {
    ODocument doc=get(collectionName,rid);
    if (doc==null) throw new InvalidParameterException(rid + " is not a valid document");
    //update the document
    DocumentDao dao = DocumentDao.getInstance(collectionName);
    dao.update(doc,(ODocument) (new ODocument()).fromJSON(bodyJson.toString()));

    return doc;//.toJSON("fetchPlan:*:0 _audit:1,rid");
  }//update
View Full Code Here

    return doc;//.toJSON("fetchPlan:*:0 _audit:1,rid");
  }//update


  public static ODocument get(String collectionName,String rid) throws IllegalArgumentException,InvalidCollectionException,InvalidModelException, ODatabaseException, DocumentNotFoundException {
    DocumentDao dao = DocumentDao.getInstance(collectionName);
    ODocument doc=dao.get(rid);

    return doc;
  }
View Full Code Here

    return doc;
  }


  public static ODocument get(String collectionName,String rid,PartsParser parser) throws IllegalArgumentException,InvalidCollectionException,InvalidModelException, ODatabaseException, DocumentNotFoundException, InvalidCriteriaException {
    DocumentDao dao = DocumentDao.getInstance(collectionName);
    ODocument doc=dao.get(rid);
    if(parser.isMultiField()){
      Object v = doc.field(parser.treeFields());

      if(v==null){
        throw new DocumentNotFoundException("Unable to find a field "+parser.treeFields()+" into document:"+rid);
View Full Code Here

    return result;
  }


  public static long getCount(String collectionName, QueryParams criteria) throws InvalidCollectionException, SqlInjectionException{
    DocumentDao dao = DocumentDao.getInstance(collectionName);
    return dao.getCount(criteria);
  }
View Full Code Here

    DocumentDao dao = DocumentDao.getInstance(collectionName);
    return dao.getCount(criteria);
  }

  public static List<ODocument> getDocuments(String collectionName, QueryParams criteria) throws SqlInjectionException, InvalidCollectionException{
    DocumentDao dao = DocumentDao.getInstance(collectionName);
    return dao.get(criteria);
  }
View Full Code Here

   * @param collectionName
   * @param rid
   * @throws Throwable
   */
  public static void delete(String collectionName, String rid) throws Throwable {
    DocumentDao dao = DocumentDao.getInstance(collectionName);
    try {
      dao.delete(rid);
    } catch (InvalidModelException e) {
      throw new InvalidCollectionException("The document " + rid + " does no belong to the collection " + collectionName);
    }
  }
View Full Code Here

    public static ArrayList<ImmutableMap> collectionsDetails(List<ODocument> collectionsthrows InvalidCollectionException {
      ODatabaseRecordTx db = DbHelper.getConnection();
      ArrayList<ImmutableMap> collMap = new ArrayList<ImmutableMap>();
      for(ODocument doc:collections){
        String collectionName = doc.field(CollectionDao.NAME);
        DocumentDao docDao = DocumentDao.getInstance(collectionName);
        long numberOfRecords=0;
        try{
          numberOfRecords=docDao.getCount();
          OClass myClass = db.getMetadata().getSchema().getClass(collectionName);
          long size=0;
          for (int clusterId : myClass.getClusterIds()) {
            size += db.getClusterRecordSizeById(clusterId);
          }
View Full Code Here

TOP

Related Classes of com.baasbox.dao.DocumentDao

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.