Package com.dotmarketing.common.db

Examples of com.dotmarketing.common.db.DotConnect


      dc.executeStatement(trigger);
    }
  }

  public void executeUpgrade() throws DotHibernateException {
    DotConnect dc = new DotConnect();
    HibernateUtil.startTransaction();
    try {
      if (DbConnectionFactory.isMsSql())
          dc.executeStatement("SET TRANSACTION ISOLATION LEVEL READ COMMITTED");
      containerTableChanges();
      htmlpageTableChanges();
      triggerChanges();
      addTriggerToFolder();
      if(Config.getBooleanProperty("upgrade-cleanup-bad-data",true))
View Full Code Here


public class Task00768CreateTagStorageFieldOnHostStructure implements StartupTask {
   
    protected void upgradeStructureFields() throws DotDataException {
        try {
            DotConnect dc=new DotConnect();
            if(DbConnectionFactory.isOracle()) {
                dc.executeStatement("alter table structure add expire_date_var varchar2(255)");
                dc.executeStatement("alter table structure add publish_date_var varchar2(255)");
            }
            else {
                dc.executeStatement("alter table structure add expire_date_var varchar(255)");
                dc.executeStatement("alter table structure add publish_date_var varchar(255)");
            }
        }
        catch(Exception ex) {
            throw new DotDataException(ex.getMessage(),ex);
        }
View Full Code Here

      StructureCache.removeStructure(structure);
      StructureServices.removeStructureFile(structure);
      StructureFactory.saveStructure(structure);
     
      //Populate host contents with tag storage value = SYSTEM_HOST
      DotConnect dc = new DotConnect();
      dc.setSQL("update contentlet set "+fieldContentlet+" = ? " +
          "where live = ? and working = ? and structure_inode in (select inode from structure where name = 'Host')"
          + " and title not like ?") ;
      dc.addParam(Host.SYSTEM_HOST);
      if(DbConnectionFactory.isPostgres()){
        dc.addParam(true);
        dc.addParam(true)
      }
      else {
        dc.addParam(DbConnectionFactory.getDBTrue());
        dc.addParam(DbConnectionFactory.getDBTrue());
      }

      dc.addParam("System Host");
      dc.loadResult();
     
    }
 
  }
View Full Code Here

        }
    }

    @Override
    protected void addBuildNewIndexEntries() throws DotDataException {
        DotConnect dc = new DotConnect();
        try {
            String sql = "insert into dist_reindex_journal(inode_to_index,ident_to_index, priority, dist_action, time_entered) " +
                  " select distinct identifier,identifier," + REINDEX_JOURNAL_PRIORITY_NEWINDEX +"," + REINDEX_ACTION_REINDEX_OBJECT + ", " + TIMESTAMPSQL +
                  " from contentlet_version_info where identifier is not null";
            dc.setSQL(sql);
            dc.loadResult();
        } catch (Exception e) {
            throw new DotDataException(e.getMessage(), e);
        }
    }
View Full Code Here

                con = DbConnectionFactory.getConnection();
                con.setAutoCommit(false);
                java.sql.Timestamp timestamp = new java.sql.Timestamp(new java.util.Date().getTime());
                for (String serversId : serversIds) {
                    if (!serverId.equals(serversId)) {
                        DotConnect dc = new DotConnect();
                        dc.setSQL("INSERT INTO dist_process(object_to_index, time_entered, serverid, journal_type)VALUES (?, ?, ?, ?)");
                        dc.addParam(key + ":" + group);
                        dc.addParam(timestamp);
                        dc.addParam(serversId);
                        dc.addParam(JOURNAL_TYPE_CACHE);
                        try {
                            dc.getResult(con);
                        } catch (Exception e) {
                            Logger
                                    .warn(this,
                                            "Usually not a problem but a cache entry failed to insert in the table.");
                            Logger.debug(this, e.getMessage(), e);
View Full Code Here

    }

    @Override
    protected void addStructureReindexEntries(T structureInode)
            throws DotDataException {
        DotConnect dc = new DotConnect();
        try {
            String sql = "insert into dist_reindex_journal(inode_to_index,ident_to_index,priority,dist_action, time_entered) " +
                " select distinct c.identifier,c.identifier,"+REINDEX_JOURNAL_PRIORITY_STRUCTURE_REINDEX+"," +
                    REINDEX_ACTION_REINDEX_OBJECT + "," + TIMESTAMPSQL  + " from contentlet c " +
                        " where c.structure_inode = ? and c.identifier is not null";
            dc.setSQL(sql);
            dc.addParam(structureInode);
            dc.loadResult();

        } catch (Exception ex) {
            Logger.fatal(this,"Error  unlocking the reindex journal table" +  ex);
        }
    }
View Full Code Here

        }
    }

    @Override
    protected boolean areRecordsLeftToIndex() throws DotDataException {
        DotConnect dc = new DotConnect();
        String serverId = ConfigUtils.getServerId();
        long count = 0;
        try {
            dc.setSQL("select count(*) as count from dist_reindex_journal");
            dc.addParam(serverId);
            List<Map<String, String>> results = dc.loadResults();
            String c = results.get(0).get("count");
            count = Long.parseLong(c);
        } catch (Exception ex) {
            Logger
            .fatal(this,"Error  unlocking the reindex journal table" +  ex);
View Full Code Here

        return count > 0;
    }

    @Override
    protected void cleanDistReindexJournal() throws DotDataException {
        DotConnect dc = new DotConnect();
        dc.setSQL("DELETE From dist_reindex_journal where priority =? or priority=?");
        dc.addParam(REINDEX_JOURNAL_PRIORITY_NEWINDEX);
        dc.addParam(REINDEX_JOURNAL_PRIORITY_NEWINDEX-10);
        dc.loadResult();
    }
View Full Code Here

    }

    @Override
    protected void deleteContentIndexEntries(String serverId, long id)
            throws DotDataException {
        DotConnect dc = new DotConnect();
        try {
            dc.setSQL("DELETE FROM dist_journal where serverid = ? and journal_type = ? and id < ?");
            dc.addParam(serverId);
            dc.addParam(JOURNAL_TYPE_CONTENTENTINDEX);
            dc.addParam(id + 1);
            dc.loadResult();
        } catch (Exception e1) {
            throw new DotDataException(e1.getMessage(), e1);
        } finally {
            try {
                HibernateUtil.closeSession();
View Full Code Here

    @Override
    protected void deleteLikeJournalRecords(IndexJournal<T> ijournal) throws DotDataException {
        String deleteLikeReindexRecords = "DELETE FROM dist_reindex_journal where serverid = ? AND ident_to_index = ? AND id <> ? ";
        String serverId = ConfigUtils.getServerId();
        DotConnect dc = new DotConnect();
        dc.setSQL(deleteLikeReindexRecords);
        dc.addParam(serverId);
        dc.addParam(ijournal.getIdentToIndex());
        dc.addParam(ijournal.getId());
        dc.loadResult();
    }
View Full Code Here

TOP

Related Classes of com.dotmarketing.common.db.DotConnect

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.