Package com.dotmarketing.db

Examples of com.dotmarketing.db.HibernateUtil


public class ContentRatingsFactory {
    public static List<Structure> getContentRatingsStructures() {
      List<Structure> list = null ;
        String query = "select {structure.*} from structure, field, inode as structure_1_ where field.field_name='Average Rating' and structure.inode=field.structure_inode and structure.inode=structure_1_.inode";
        HibernateUtil dh = new HibernateUtil (Structure.class);
        try {
      dh.setSQLQuery(query);
      list = dh.list();
    } catch (DotHibernateException e) {
      Logger.error(ContentRatingsFactory.class, e.getMessage(), e);
    }
        return list;
    }
View Full Code Here


    public static List<Rating> getContentRatingsByStructure(String inode) {
      List<Rating> result = null;
     
      try {
        String query = "select {content_rating.*} from content_rating, contentlet,inode where content_rating.identifier = contentlet.identifier and inode.inode = contentlet.inode and structure_inode=?";
        HibernateUtil dh = new HibernateUtil (Rating.class);
        dh.setSQLQuery(query);
        dh.setParam(inode);
        result = dh.list();
      } catch (Exception e) {
        Logger.error(ContentRatingsFactory.class, "", e);
        return null;
      }
     
View Full Code Here

   */
  public File getWorkingFileByFileName(String fileName, Folder folder) throws DotDataException{

    Identifier id = APILocator.getIdentifierAPI().find(folder);

      HibernateUtil hu = new HibernateUtil(File.class);
      hu.setSQLQuery(workingFileByName);
      hu.setParam(id.getPath());
      hu.setParam(id.getHostId());
      hu.setParam(fileName);

      return (File) hu.load();


  }
View Full Code Here

  public File getLiveFileByFileName(String fileName, Folder folder) throws DotDataException{

    Identifier id = APILocator.getIdentifierAPI().find(folder);

      HibernateUtil hu = new HibernateUtil(File.class);
      hu.setSQLQuery(liveFileByName);
      hu.setParam(id.getPath());
      hu.setParam(fileName);

      return (File) hu.load();


  }
View Full Code Here

  }


  @SuppressWarnings("unchecked")
  public List<File> getAllHostFiles(Host host, boolean live) throws DotDataException {
    HibernateUtil hu = new HibernateUtil(File.class);
    StringBuilder queryBuilder = new StringBuilder("select {file_asset.*} from file_asset, inode file_asset_1_,identifier ident, fileasset_version_info vi "
        + "where file_asset.inode = file_asset_1_.inode and " + "file_asset.identifier = ident.id and asset_type='file_asset' and ident.id=vi.identifier "
        + " and ident.host_inode = ? ");
    if (live)
      queryBuilder.append(" and vi.live_inode=file_asset.inode ");
    else
      queryBuilder.append(" and vi.working_inode=file_asset.inode ");

    hu.setSQLQuery(queryBuilder.toString());
    hu.setParam(host.getIdentifier());

    return hu.list();
  }
View Full Code Here

    return hu.list();
  }

  @SuppressWarnings("unchecked")
  public File getWorkingFileById(String identifier) throws DotDataException {
    HibernateUtil hu = new HibernateUtil(File.class);
    hu.setSQLQuery("select {file_asset.*} from file_asset, inode file_asset_1_, fileasset_version_info vi " +
        " where file_asset.identifier = ? and vi.identifier=file_asset.identifier and vi.working_inode=file_asset.inode "
        + "and file_asset_1_.inode = file_asset.inode");
    hu.setParam(identifier);
    List<File> files = hu.list();
    if (files.size() == 0)
      return null;
    return files.get(0);
  }
View Full Code Here

     
    }
 
 
  public Folder getFileFolder(File file, String hostId) throws DotDataException {
    HibernateUtil hu = new HibernateUtil(Folder.class);
    hu.setSQLQuery("select {folder.*} from folder,identifier,inode folder_1_ where folder.identifier = identifier.id and "
        + "folder_1_.inode = folder.inode and host_inode = ? and path =(select parent_path from identifier where id=?)");

    hu.setParam(hostId);
    hu.setParam(file.getIdentifier());
    return (Folder) hu.load();
  }
View Full Code Here

    if (!UtilMethods.isSet(orderBy)) {
      orderBy = "modDate desc";
    }

    List<File> resultList = new ArrayList<File>();
    HibernateUtil dh = new HibernateUtil(File.class);
    String type;
    int countLimit = 100;
    int size = 0;
    try {
      type = ((Inode) File.class.newInstance()).getType();
      query.append(" and asset.type='").append(type).append("' ");
      final String conditions=conditionBuffer.toString().trim();
      if(conditions.length()>0)
          query.append(" and ").append(conditions);
      query.append(" order by asset.").append(orderBy);
      dh.setQuery(query.toString());

      if (paramValues != null && paramValues.size() > 0) {
        for (Object value : paramValues) {
          dh.setParam((String) value);
        }
      }

      while (!done) {
        dh.setFirstResult(internalOffset);
        dh.setMaxResults(internalLimit);
        resultList = dh.list();
        PermissionAPI permAPI = APILocator.getPermissionAPI();
        toReturn.addAll(permAPI.filterCollection(resultList, PermissionAPI.PERMISSION_READ, false, user));
        if (countLimit > 0 && toReturn.size() >= countLimit + offset)
          done = true;
        else if (resultList.size() < internalLimit)
View Full Code Here

                perAPI.removePermissions(link);

              List<Versionable> versions =APILocator.getVersionableAPI().findAllVersions(identifier, APILocator.getUserAPI().getSystemUser(), false);
             
              for (Versionable version : versions) {
          new HibernateUtil().delete(version);
              }
              APILocator.getIdentifierAPI().delete(identifier);
      }
    }
   
View Full Code Here

        if (!x.equals(Inode.class) && !x.equals(Clickstream.class) && !x.equals(ClickstreamRequest.class) && !x.equals(Clickstream404.class))
          _tablesToDump.add(x);

      }
      XStream _xstream = null;
      HibernateUtil _dh = null;
      List _list = null;
      File _writing = null;
      BufferedOutputStream _bout = null;

      for (Class clazz : _tablesToDump) {
        //http://jira.dotmarketing.net/browse/DOTCMS-5031
                if(PermissionReference.class.equals(clazz)){
                  continue;
                }

        _xstream = new XStream(new DomDriver());

        //http://jira.dotmarketing.net/browse/DOTCMS-6059
        if(clazz.equals(DashboardSummary404.class) || clazz.equals(DashboardUserPreferences.class)){
          _xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Set.class, java.util.Set.class);
          _xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.List.class, java.util.List.class);
          _xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Map.class, java.util.Map.class);
          Mapper mapper = _xstream.getMapper();
          _xstream.registerConverter(new HibernateCollectionConverter(mapper));
          _xstream.registerConverter(new HibernateMapConverter(mapper));
        }

        /*
         * String _shortClassName =
         * clazz.getName().substring(clazz.getName().lastIndexOf("."),clazz.getName().length());
         * xstream.alias(_shortClassName, clazz);
         */
        int i= 0;
        int step = 1000;
        int total =0;
        java.text.NumberFormat formatter = new java.text.DecimalFormat("0000000000");
        /* we will only export 10,000,000 items of any given type */
        for(i=0;i < 10000000;i=i+step){

                    _dh = new HibernateUtil(clazz);
                    _dh.setFirstResult(i);
                    _dh.setMaxResults(step);

                    //This line was previously like;
                    //_dh.setQuery("from " + clazz.getName() + " order by 1,2");
                    //This caused a problem when the database is Oracle because Oracle causes problems when the results are ordered
                    //by an NCLOB field. In the case of containers table, the second field, CODE, is an NCLOB field. Because of this,
                    //ordering is done only on the first field for the tables, which is INODE
                    if(com.dotmarketing.beans.Tree.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by parent, child, relation_type");
                    }
                    else if(MultiTree.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by parent1, parent2, child, relation_type");
                    }
                    else if(TagInode.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by inode, tag_id");
                    }
                    else if(Tag.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by tag_id, tagname");
                    }
                    else if(CalendarReminder.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by user_id, event_id, send_date");
                    }
                    else if(Identifier.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by parent_path");
                    } else {
                      _dh.setQuery("from " + clazz.getName() + " order by 1");
                    }

                    _list = _dh.list();
                    if(_list.size() ==0){
                        try {
                        _bout.close();
                        }
                        catch( java.lang.NullPointerException npe){}
View Full Code Here

TOP

Related Classes of com.dotmarketing.db.HibernateUtil

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.