コード例 #1
0
  /**
   * Returns the objects collection.
   *
   * @param
   */
  protected IObjects getIObjects(int _nMaxSize) throws PureException {
    SearchForm thisform = (SearchForm) form;

    // 1. to get the query filter
    QueryFilter filter = thisform.getQueryFilter();
    if (filter.getSelect() == null) {
      filter.addPropertySelect("this", "*");
    }

    // 2. to render SQL
    IContentMgr mgr =
        ArkContentHelper.getContentMgrOf(thisform.getEntityMetadata().getEntityClass());
    List params = new ArrayList();
    String strSQL = filter.toSQL(params);
    if (this.isFromTemp()) {
      strSQL = strSQL.replaceAll("\\{this\\}", mgr.getTempTable(true) + " this");
    }
    logger.debug("SQL=" + strSQL);

    // 3. to execute the query
    IStatement query = null;
    try {
      query = mgr.createQuery(strSQL, 0);
      filter.registerEntitiesInQuery(query);
      query.setParameters(0, params);
      if (_nMaxSize > 0) {
        query.setMaxSize(_nMaxSize);
      }
      return query.executeQuery();
    } finally {
      params.clear();
      if (query != null) query.clear();
    }
  }
コード例 #2
0
 private int getPublicationId(String _sISSN) throws PureException {
   IStatement query = null;
   IObjects result = null;
   try {
     IContentMgr mgr = ArkContentHelper.getContentMgrOf(Publication.class);
     final String strSQL = "SELECT * FROM {this} WHERE {this.publishCode}='" + _sISSN + '\'';
     query = mgr.createQuery(strSQL, 1);
     result = query.executeQuery();
     Publication publication = (Publication) result.next();
     if (publication != null) return publication.getId();
     return 0;
   } finally {
     DolphinHelper.clear(result, query);
   }
 }
コード例 #3
0
 /** @see com.pureinfo.srm.project.domain.IProjectPersonMgr#findAllByRelativeId(int) */
 protected void deleteAllByRelativeId(DolphinObject _newObj, String _sRelativeIdName, Class _clazz)
     throws PureException {
   IStatement query = null;
   try {
     String strSQL = "SELECT * FROM {this} WHERE {this." + _sRelativeIdName + "} = ?";
     IContentMgr mgr = ArkContentHelper.getContentMgrOf(_clazz);
     query = mgr.createQuery(strSQL, 0);
     query.setInt(0, _newObj.getIntProperty("id", 0));
     mgr.delete(query.executeQuery());
   } catch (Exception ex) {
     ex.printStackTrace(System.err);
     throw new PureException(
         SRMExceptionTypes.PP_FINDALL_PERSONS_OFPROJECT,
         "RelativeId: " + _newObj.getIntProperty("id", 0),
         ex);
   } finally {
     if (query != null) {
       query.clear();
     }
     LocalContextHelper.closeSession();
   }
 }
コード例 #4
0
  /** Exports object list. */
  protected ActionForward doExport() throws PureException {
    SearchForm thisform = (SearchForm) form;
    IObjects exObjs = null;
    try {
      // 1. to fetch the objects collection
      if (thisform.getExportMode() == SearchForm.EX_MODE_SELECTED
          && thisform.getExportIds() != null) {
        Class entityClass = thisform.getEntityMetadata().getEntityClass();
        IContentMgr mgr = ArkContentHelper.getContentMgrOf(entityClass);
        if (!isFromTemp()) {
          exObjs = mgr.lookupByIds(thisform.getExportIds());
        } else {
          String strSQL =
              "SELECT * FROM "
                  + thisform.getEntityMetadata().getTempTable()
                  + " WHERE {this.id} IN ("
                  + thisform.getExportIds()
                  + ")";
          ISession session = LocalContextHelper.currentSession();
          IStatement query = session.createQuery(strSQL, entityClass, 0);
          try {
            exObjs = query.executeQuery();
          } finally {
            query.clear();
          }
        }
      } else {
        exObjs = getIObjects();
      }

      // 2. to prepare the columns
      ListHelper lh = new ListHelper();
      lh.setSenery(getScenery());
      List baseCols = thisform.getColunms();
      String sClassName = exObjs.getElementClass().getName();
      if (baseCols == null || baseCols.size() < 1) {
        baseCols = lh.prepareBase(exObjs.getElementClass().getName());
      }

      lh.setSenery(getExportSenery());
      lh.setAct("content");

      List colInfos =
          lh.prepareColsInfo(baseCols, getInclude(), getExclude(), null, sClassName, false);
      String[] headers = new String[colInfos.size()];
      String[] properties = new String[colInfos.size()];
      SceneryContext sceneryContext = null;
      try {
        boolean bUsePropertyName = (thisform.getExportType() == ExportHelper.TYPE_XML);
        String sHeader;
        for (int i = 0; i < colInfos.size(); i++) {
          ColumnInfo colInfo = (ColumnInfo) colInfos.get(i);
          if (bUsePropertyName) {
            sHeader = colInfo.getOldName();
          } else {
            sHeader = colInfo.getTitle();
            if (sHeader.indexOf('$') >= 0) {
              if (sceneryContext == null) {
                IDVContextFactory factory =
                    (IDVContextFactory) PureFactory.getBean("IDVContextFactory");
                DolphinObject obj = (DolphinObject) exObjs.getElementClass().newInstance();
                sceneryContext =
                    factory.createSceneryContext(obj, getExportSenery(), "plain.default");
              }
              sHeader = Executer.execute(ScriptReader.readBlock(sHeader), sceneryContext);
            }
          }
          headers[i] = sHeader.replaceAll("[\\\\\\[\\]\\?/<>]+", "_");
          properties[i] = colInfo.getName();
        }
      } catch (Exception ex) {
        throw new PureException(ArkExceptionTypes.EXPORT_CONTENTS, "failed to get the headers", ex);
      } finally {
        if (sceneryContext != null) {
          sceneryContext.clear();
        }
        colInfos.clear();
      }

      // 3. to prepare the data
      IConvertor convertor = new ExportConvertor(getExportSenery(), "content");
      DolphinExportGoods goods = new DolphinExportGoods();
      goods.setType(thisform.getExportType());
      goods.setName(getTitle());
      goods.setHeaders(headers);
      goods.setData(exObjs, properties, convertor);

      // 4. to return
      request.setAttribute("export", goods);
      return mapping.findForward("guest-export");
    } finally {
      LocalContextHelper.closeSession();
    }
  }
コード例 #5
0
 public static String getNameById(int _nId) throws PureException {
   IContentMgr mgr = ArkContentHelper.getContentMgrOf(Organization.class);
   Organization inst = (Organization) mgr.lookupById(_nId);
   return inst == null ? ReportHelper.ERROR_TYPE_NAME + _nId : inst.getName();
 }