Examples of ODatabaseRecordTx


Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

      dbFreeze.set(false);
    }
  }
 
  public static void importData(String appcode,String importData) throws UnableToImportDbException{
    ODatabaseRecordTx db = null;
    java.io.File f = null;
    try{
      Logger.info("Initializing restore operation..:");
      Logger.info("...dropping the old db..:");
      DbHelper.shutdownDB(false);
      f = java.io.File.createTempFile("import", ".json");
      FileUtils.writeStringToFile(f, importData);
      synchronized(DbHelper.class)  {
        if(!dbFreeze.get()){
          dbFreeze.set(true);
        }
      }

      db=getConnection();
      Logger.info("...unregistering hooks...");
      HooksManager.unregisteredAll(db);
      Logger.info("...drop the O-Classes...");
      db.getMetadata().getSchema().dropClass("OFunction");
       db.getMetadata().getSchema().dropClass("OSchedule");
       db.getMetadata().getSchema().dropClass("ORIDs");
         ODatabaseDocumentTx dbd = new ODatabaseDocumentTx(db);
      ODatabaseImport oi = new ODatabaseImport(dbd, f.getAbsolutePath(), new OCommandOutputListener() {
        @Override
        public void onMessage(String m) {
          Logger.info("Restore db: " + m);
        }
      });
     
       oi.setIncludeManualIndexes(true);
       oi.setUseLineFeedForRecords(true);
       oi.setPreserveClusterIDs(true);
       oi.setPreserveRids(true);
       Logger.info("...starting import procedure...");
       oi.importDatabase();
       oi.close();
     
       Logger.info("...setting up internal user credential...");
       updateDefaultUsers();
       Logger.info("...setting up DataBase attributes...");
       setupAttributes();
       Logger.info("...registering hooks...");
       evolveDB(db);
       HooksManager.registerAll(db);
       Logger.info("...extract iOS certificates...");
       IosCertificateHandler.init();
    }catch(Exception ioe){
      Logger.error("*** Error importing the db: ", ioe);
      throw new UnableToImportDbException(ioe);
    }finally{
      if(db!=null && ! db.isClosed()){
        db.close();
      }
      Logger.info("...releasing the db...");
      dbFreeze.set(false);
      if(f!=null && f.exists()){
        f.delete();
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

      Logger.info("...restore terminated");
    }
  }

  private static void setupAttributes() {
    ODatabaseRecordTx db = DbHelper.getConnection();
    DbHelper.execMultiLineCommands(db,Logger.isDebugEnabled(),
        "alter database DATETIMEFORMAT yyyy-MM-dd'T'HH:mm:ss.sssZ"
        ,"alter database custom useLightweightEdges=false"
        ,"alter database custom useClassForEdgeLabel=false"
        ,"alter database custom useClassForVertexLabel=true"
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

    ODocument doc=get((ORecordId)orid);
    return doc;
  }
 
  public ODocument get(ORID rid) {
    ODatabaseRecordTx db =DbHelper.getConnection();
    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    ODocument doc=db.load(rid);
    if (Logger.isTraceEnabled()) Logger.trace("Method End");
    return doc;
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

   * Returns a _BB_NODE element by its id (not RID)
   * @param id
   * @return
   */
  public ORID getRidNodeByUUID(String id){
    ODatabaseRecordTx db =DbHelper.getConnection();
    OIndex<?> index = db.getMetadata().getIndexManager().getIndex("_BB_Node.id");
    ORID rid = (ORID) index.get(id)
    return rid;
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

   * Executes a generic OrientDB SQL Command
   * @param commandString
   * @param params
   */
  public void executeCommand(String commandString, Object[] params) {
    ODatabaseRecordTx db =  DbHelper.getConnection();
    OCommandRequest command=db.command(new OCommandSQL(commandString));
    //Logger.debug("########## is in transaction??  : " + db.getTransaction().isActive());
    command.execute(params);
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

      if (Logger.isTraceEnabled()) Logger.trace("Method Start");
      UserDao userDao = UserDao.getInstance();
      CollectionDao collDao = CollectionDao.getInstance();
      AssetDao assetDao = AssetDao.getInstance();
      FileDao fileDao = FileDao.getInstance();
      ODatabaseRecordTx db = DbHelper.getConnection();
     
      long usersCount =userDao.getCount();
      long assetsCount = assetDao.getCount();
      long collectionsCount = collDao.getCount();
      long filesCount = fileDao.getCount();
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

     * @param collections list of ODocuments representing the defined collections
     * @return for each collection: its name, the number of documents, and the total size that the collection takes up
     * @throws InvalidCollectionException
     */
    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);
          }
          collMap.add(ImmutableMap.of(
              "name",collectionName,
              "records", numberOfRecords,
              "size",size
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

      return content;
    }
   
    public static ImmutableMap db() {
      if (Logger.isTraceEnabled()) Logger.trace("Method Start");
      ODatabaseRecordTx db = DbHelper.getConnection();
      HashMap dbProp= new HashMap();
      dbProp.put("version", OConstants.getVersion());
      dbProp.put("url", OConstants.ORIENT_URL);
      if (BBConfiguration.getStatisticsSystemOS()) dbProp.put("path", db.getStorage().getConfiguration().getDirectory());
      else dbProp.put("path", "N/A");
      dbProp.put("timezone", db.getStorage().getConfiguration().getTimeZone());
      dbProp.put("locale.language", db.getStorage().getConfiguration().getLocaleLanguage());
      dbProp.put("locale.country", db.getStorage().getConfiguration().getLocaleCountry());
     
      HashMap map = new HashMap();
      map.put("properties", dbProp);
      map.put("status", db.getStatus());
      map.put("configuration", dbConfiguration());
      map.put("physical_size", DbHelper.getDBTotalSize());
      map.put("datafile_freespace", DbHelper.getDBStorageFreeSpace());
      map.put("size_threshold_percentage", BBConfiguration.getDBAlertThreshold());
     
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

    public static final String  READER_BASE_ROLE = "reader";
    public static final String  WRITER_BASE_ROLE = "writer";
    public static final String  ADMIN_BASE_ROLE = "admin";
   
    public static ORole getRole(String name){
      ODatabaseRecordTx db = DbHelper.getConnection();
            return db.getMetadata().getSecurity().getRole(name);
        }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

      ODatabaseRecordTx db = DbHelper.getConnection();
            return db.getMetadata().getSecurity().getRole(name);
        }

    public static ORole createRole(String name,String inheritedRoleName){
      ODatabaseRecordTx db = DbHelper.getConnection();
      ORole inheritedRole = db.getMetadata().getSecurity().getRole(inheritedRoleName);
      final ORole role =  db.getMetadata().getSecurity().createRole(name,inheritedRole.getMode());
      role.getDocument().field(FIELD_INHERITED,inheritedRole.getDocument().getRecord());
      role.save();
          return role;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.