Package com.dotmarketing.db

Examples of com.dotmarketing.db.HibernateUtil



  }
  @Override
  public List<HTMLPage> getPagesUsingTemplate(Template template) throws DotDataException {
    HibernateUtil hu = new HibernateUtil(HTMLPage.class);
    hu.setSQLQuery(workingVersionPagesUsingTemplateSQL);
    hu.setParam(template.getIdentifier());
    List<HTMLPage> workingPages = new ArrayList<HTMLPage>(new HashSet<HTMLPage>(hu.list()));
    if(workingPages.size() > 0){
      return workingPages;
    }else{
      HibernateUtil hu1 = new HibernateUtil(HTMLPage.class);
      hu1.setSQLQuery(nonWorkingVersionPagesUsingTemplateSQL);
      hu1.setParam(template.getIdentifier());
      List<HTMLPage> nonWorkingPages = new ArrayList<HTMLPage>(new HashSet<HTMLPage>(hu1.list()));
      return nonWorkingPages; 
    }
  }
View Full Code Here


  private static VersionInfo getVersionInfo(WebAsset currWebAsset,
      Identifier identifier, List<Versionable> webAssetList, String type)
      throws DotHibernateException {
    VersionInfo auxVersionInfo;
    Class clazz = UtilMethods.getVersionInfoType(type);
    HibernateUtil dh = new HibernateUtil(clazz);
    dh.setQuery("from "+clazz.getName()+" where identifier=?");
    dh.setParam(identifier);
    Logger.debug(BaseWebAssetAPI.class, "getVersionInfo query: "+dh.getQuery());
    auxVersionInfo=(VersionInfo)dh.load();

    if(UtilMethods.isSet(auxVersionInfo) && UtilMethods.isSet(auxVersionInfo.getIdentifier())) {
        clazz = InodeUtils.getClassByDBType(type);
        dh = new HibernateUtil(clazz);
      dh.setQuery("from inode in class " + clazz.getName() + " where inode.identifier = ? and inode.type='"+type+"' order by mod_date desc");
      dh.setParam(currWebAsset.getIdentifier());
      Logger.debug(BaseWebAssetAPI.class, "findAllVersions query: " + dh.getQuery());
      webAssetList.addAll( (List<Versionable>) dh.list() );
    }
    return auxVersionInfo;
  }
View Full Code Here

      "htmlpage.inode = htmlpage_1_.inode";


  @SuppressWarnings("unchecked")
  public List<Template> findTemplatesUnder(Folder parentFolder) throws DotStateException, DotDataException {
    HibernateUtil hu = new HibernateUtil(Template.class);
    hu.setSQLQuery(subTemplatesSQL);
    hu.setParam(APILocator.getIdentifierAPI().find(parentFolder).getPath());
    return new ArrayList<Template>(new HashSet<Template>(hu.list()));
  }
View Full Code Here

    Template template = templateCache.get(inode);
   
    if(template==null){
   
   
      HibernateUtil hu = new HibernateUtil(Template.class);
      template = (Template) hu.load(inode);
      if(template != null && template.getInode() != null)
        templateCache.add(inode, template);
    }
    return template;
  }
View Full Code Here

 
 
 
  @SuppressWarnings("unchecked")
  public List<Template> findTemplatesAssignedTo(Host parentHost, boolean includeArchived) throws DotHibernateException {
    HibernateUtil hu = new HibernateUtil(Template.class);
    String query = !includeArchived?templatesUnderHostSQL + " and vi.deleted = " + DbConnectionFactory.getDBFalse():templatesUnderHostSQL;
    hu.setSQLQuery(templatesUnderHostSQL);
    hu.setParam(parentHost.getIdentifier());
    return new ArrayList<Template>(new HashSet<Template>(hu.list()));
  }
View Full Code Here

    CacheLocator.getIdentifierCache().removeFromCacheByVersionable(template);
  }

  @SuppressWarnings("unchecked")
  public Template findWorkingTemplateByName(String name, Host host) throws DotDataException {
    HibernateUtil hu = new HibernateUtil(Template.class);
    hu.setSQLQuery(templateWithNameSQL);
    hu.setParam(host.getIdentifier());
    hu.setParam(name);
    return (Template) hu.load();

  }
View Full Code Here

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

    List<Template> resultList = new ArrayList<Template>();
    HibernateUtil dh = new HibernateUtil(Template.class);
    String type;
    int countLimit = 100;
    int size = 0;
    try {
      type = ((Inode) Template.class.newInstance()).getType();
      query.append(" and asset.type='"+type+ "' and " + conditionBuffer.toString() + " order by asset." + 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

    }
    return list;
  }
 
  public static java.util.List getUserFilterByTitleAndUser(String title, User user) {
    HibernateUtil dh = new HibernateUtil(UserFilter.class);
    List<UserFilter> list =null;
    try {
      dh.setSQLQuery("select user_filter.* from user_filter user_filter, inode inode where lower(user_filter.title) like ? and user_filter.inode=inode.inode and inode.owner=? order by title");
      dh.setParam("%" + title.toLowerCase() + "%");
      dh.setParam(user.getUserId());
      list = dh.list();
    } catch (DotHibernateException e) {
      Logger.error(UserFilterFactory.class, "getUserFilterByTitleAndUser failed:" + e, e);
    }
    return list;
  }
View Full Code Here

   * @param report The report to load parametrs for
   * @return void
   */ 
  public static void getReportParameters(Report report)throws DotHibernateException{
    if(report.isRequiresInput()){
      HibernateUtil hu = new HibernateUtil(ReportParameter.class);
      hu.setQuery(GETAllRPHQL);
      hu.setParam(report.getInode());
      report.setParameters(new ArrayList<ReportParameter>(hu.list()));
    }
  }
View Full Code Here

    * Get a specific report
    * @param    reportId
    * @return    Report
    */
  public static Report getReport(String reportId)throws DotHibernateException{
    HibernateUtil hu = new HibernateUtil(Report.class);
    return (Report)hu.load(reportId);
  }
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.