/**
   * @see com.pureinfo.importer.ref.IImportorRef#convert(com.pureinfo.dolphin.model.DolphinObject,
   *     com.pureinfo.dolphin.model.DolphinObject, java.lang.String, java.lang.String,
   *     com.pureinfo.dolphin.persister.ISession, com.pureinfo.dolphin.persister.ISession,
   *     com.pureinfo.dolphin.mapping.EntityMetadata, java.lang.String, java.lang.String)
   */
  public Object convert(
      DolphinObject _old,
      DolphinObject _new,
      String _sFromProperty,
      String _sToProperty,
      ISession _fromSession,
      ISession _toSession,
      EntityMetadata _metadata,
      String _sKey,
      String _sToTable)
      throws PureException {
    int objId = _new.getIntProperty("id", 0);
    IPatentMgr mgr = (IPatentMgr) ArkContentHelper.getContentMgrOf(SRMTypes.PATENT);

    Patent patent = (Patent) mgr.lookupById(objId);
    if (patent == null) {
      return null;
    }
    if (mgr.openIsAuth(patent.getPatentType())) {
      patent.setStatus(SRMConstants.PATENT_STATUS_HAS_RIGHT);
      patent.setWarrantDate(patent.getPublicDate());
      patent.setProbWeight(WeightCalcHelper.getWeightCalculator(patent).calcProbWeight());
      mgr.save(patent);
    }
    return null;
  }
 private static void update0(int _nProductForm) throws PureException {
   IStatement query = null;
   IObjects result = null;
   try {
     int[] aValues = { //
       //            1964,//
       //                    1978, 1979,//
       //                    1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989,//
       1990,
       1991,
       1992,
       1993,
       1994,
       1995,
       1996,
       1997,
       1998,
       1999, //
       2000,
       2001,
       2002,
       2003,
       2004,
       2005,
       2006 //
     };
     IProductMgr mgr = (IProductMgr) ArkContentHelper.getContentMgrOf(Product.class);
     String strSQL =
         "SELECT {this.id},{this.serialNo},{this.publishDate} FROM {this}0 WHERE {this.productForm}="
             + _nProductForm
             + " AND year({this.publishDate})=?";
     for (int j = 0; j < aValues.length; j++) {
       query = mgr.createQuery(strSQL, 0);
       query.setInt(0, aValues[j]);
       result = query.executeQuery();
       int max =
           getMaxSerialNo(
               "SELECT MAX({this.serialNo}) AS _MAX FROM {this} WHERE {this.productForm}="
                   + _nProductForm
                   + " AND year({this.publishDate})="
                   + aValues[j]);
       //                int max=2005608586;
       int i = max;
       for (Iterator iter = result.iterator(); iter.hasNext(); i++) {
         Product product = (Product) iter.next();
         int nSerialNo = 0;
         if (max > 1) {
           nSerialNo = i;
         } else {
           nSerialNo = aValues[j] * 1000000 + 100000 * _nProductForm + i;
         }
         System.out.println(product.getId() + " : " + nSerialNo);
         product.setProperty("serialNo", nSerialNo);
         mgr.saveToTemp(product, false);
       }
     }
   } finally {
     DolphinHelper.clear(result, query);
   }
 }
コード例 #3
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();
    }
  }
コード例 #4
0
  /**
   * @see com.pureinfo.importer.ref.IImportorRef#convert(com.pureinfo.dolphin.model.DolphinObject,
   *     com.pureinfo.dolphin.model.DolphinObject, java.lang.String, java.lang.String,
   *     com.pureinfo.dolphin.persister.ISession, com.pureinfo.dolphin.persister.ISession,
   *     com.pureinfo.dolphin.mapping.EntityMetadata, java.lang.String, java.lang.String)
   */
  public Object convert(
      DolphinObject _old,
      DolphinObject _new,
      String _sFromProperty,
      String _sToProperty,
      ISession _fromSession,
      ISession _toSession,
      EntityMetadata _metadata,
      String _sKey,
      String _sToTable)
      throws PureException {
    String sPrjNumber = _old.getStrProperty(_sFromProperty);
    Project project = null;
    IObjects projects = null;
    IStatement query = null;
    try {
      IProjectMgr mgr = (IProjectMgr) ArkContentHelper.getContentMgrOf(Project.class);
      query = mgr.createQuery("SELECT * FROM {this} WHERE {this.projectNumber}=?", 1);
      query.setString(0, sPrjNumber);
      projects = query.executeQuery();
      project = (Project) projects.next();
    } finally {
      DolphinHelper.clear(projects, query);
    }

    if (project != null) {
      _new.setProperty("bigChecked", true);
      return "1";
    }
    _new.setProperty("bigChecked", false);
    return "0";
  }
コード例 #5
0
 /** @see com.pureinfo.ark.interaction.ActionBase#executeAction() */
 public ActionForward executeAction() throws PureException {
   int nCollegeId = request.getRequiredInt("college", "ѧԺID");
   IOrganizationMgr mgr = (IOrganizationMgr) ArkContentHelper.getContentMgrOf(Organization.class);
   List listIns = mgr.getChildren(nCollegeId, true);
   Document sInsJson = makeXML(listIns);
   writeResponse(sInsJson);
   return null;
 }
コード例 #6
0
 /**
  * @param org2Names
  * @param org2Ids
  * @throws PureException
  */
 private void setOrg2(List org2Names, List org2Ids) throws PureException {
   IOrganizationMgr mgr = (IOrganizationMgr) ArkContentHelper.getContentMgrOf(Organization.class);
   List objs = mgr.findAllByType(SRMConstants.ORG_TYPE.ACADEMY, true);
   for (Iterator iter = objs.iterator(); iter.hasNext(); ) {
     Organization dept = (Organization) iter.next();
     org2Names.add(dept.getName());
     org2Ids.add(new Integer(dept.getId()));
   }
 }
コード例 #7
0
  /**
   * @param _sTeamId
   * @throws PureException
   */
  public void deleteAllMember(int _sTeamId) throws PureException {
    if (logger.isDebugEnabled()) {
      logger.debug("to deleteAllMember...");
    }

    ITeamMemberMgr memberMgr =
        (ITeamMemberMgr) ArkContentHelper.getContentMgrOf(SRMTypes.TEAM_MEMBER);
    memberMgr.deleteAllByTeamId(_sTeamId);
  }
コード例 #8
0
 private void saveDepts(Team _team, List _deptList) throws PureException {
   IObjDeptMappingMgr mgr =
       (IObjDeptMappingMgr) ArkContentHelper.getContentMgrOf(SRMTypes.OBJ_DEPT_MAPPING);
   ObjDeptMapping dept;
   for (Iterator iterator = _deptList.iterator(); iterator.hasNext(); ) {
     dept = (ObjDeptMapping) iterator.next();
     dept.setObjId(_team.getId());
     mgr.save(dept);
   }
 }
コード例 #9
0
  /**
   * @param _sTeam
   * @param _sLoginUser
   * @throws PureException
   */
  public void delete(Team _sTeam, IUser _sLoginUser) throws PureException {
    ITeamMgr teamMgr = (ITeamMgr) ArkContentHelper.getContentMgrOf(SRMTypes.TEAM);
    this.deleteAllMember(_sTeam.getId());
    this.deleteAllDepts(_sTeam);

    if (_sTeam.isFromFormal()) {
      teamMgr.delete(_sTeam);
    } else {
      teamMgr.deleteTempById(_sTeam.getId());
    }
  }
コード例 #10
0
  /**
   * @param _sTeam
   * @param _sLoginUser
   * @throws PureException
   */
  public void doEditFromFormal(Team _sTeam, IUser _sLoginUser) throws PureException {
    ITeamMgr teamMgr = (ITeamMgr) ArkContentHelper.getContentMgrOf(SRMTypes.TEAM);

    List list = _sTeam.getMemberList();
    teamMgr.save(_sTeam);
    this.deleteAllMember(_sTeam.getId());
    this.saveMember(_sTeam.getId(), list);

    List deptList = _sTeam.getDeptList();
    this.deleteAllDepts(_sTeam);
    this.saveDepts(_sTeam, deptList);
  }
コード例 #11
0
 /** @see com.pureinfo.ark.interaction.ActionBase#executeAction() */
 public ActionForward executeAction() {
   AddEditForm roleForm = (AddEditForm) form;
   try {
     Role role = (Role) roleForm.getObj();
     IRoleMgr mgr = (IRoleMgr) ArkContentHelper.getContentMgrOf(Role.class);
     mgr.save(role);
     return mapping.findForward("editRoleSuccess");
   } catch (Exception ex) {
     ex.printStackTrace(System.err);
     return mapping.findForward("editRoleFailure");
   } finally {
     LocalContextHelper.closeSession();
   }
 }
コード例 #12
0
  /**
   * @param _nTeamId
   * @param list
   * @throws PureException
   */
  public void saveMember(int _nTeamId, List list) throws PureException {
    if (logger.isDebugEnabled()) {
      logger.debug("to saveMember...");
    }

    logger.debug("there's " + list.size() + " members");
    ITeamMemberMgr memberMgr =
        (ITeamMemberMgr) ArkContentHelper.getContentMgrOf(SRMTypes.TEAM_MEMBER);
    for (Iterator iter = list.iterator(); iter.hasNext(); ) {
      TeamMember element = (TeamMember) iter.next();
      element.setTeamId(_nTeamId);
      memberMgr.save(element);
    }
  }
コード例 #13
0
  /**
   * @param _nPatentId
   * @throws PureException
   */
  private void updateOnePatent(int _nPatentId) throws PureException {
    IPatentMgr patentMgr = (IPatentMgr) ArkContentHelper.getContentMgrOf(Patent.class);
    Patent checkPatent = (Patent) patentMgr.lookupById(_nPatentId);
    if (request.getParameter("actionType").equals("cer")) {
      checkPatent.setIsCerSave(1);
      checkPatent.setCerDate(new Date());
    }
    //        else if(request.getParameter("actionType").equals("datum")){
    //            checkPatent.setIsDatumSave(1);
    //            checkPatent.setDatumDate(new Date());
    //        }

    patentMgr.save(checkPatent);
  }
コード例 #14
0
  public String getMessage() throws PureException {
    IProductMgr mgr = (IProductMgr) ArkContentHelper.getContentMgrOf(Product.class);
    QueryFilter filter = ((SearchForm) form).getQueryFilter();

    int nProductForm = request.getInt("dp_productForm", "productForm", 0);
    if (nProductForm == 0) {
      nProductForm = request.getInt("paperForm", "productForm", 0);
      if (nProductForm == 0) {
        logger.debug("未知成果类型");
        return super.getMessage();
      }
    }

    return mgr.getMessageInfo(filter, nProductForm);
  }
コード例 #15
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);
   }
 }
コード例 #16
0
 private static int getMaxSerialNo(String _sSQL) throws PureException {
   IStatement query = null;
   IObjects result = null;
   try {
     IProductMgr mgr = (IProductMgr) ArkContentHelper.getContentMgrOf(Product.class);
     query = mgr.createQuery(_sSQL, 0);
     result = query.executeQuery();
     Product product = (Product) result.next();
     if (product == null) {
       return 1;
     }
     return product.getIntProperty("_MAX", 0) + 1;
   } finally {
     DolphinHelper.clear(result, query);
   }
 }
コード例 #17
0
  /**
   * @param _sTeam
   * @param _sLoginUser
   * @throws PureException
   */
  public void doEditFromTemp(Team _sTeam, IUser _sLoginUser) throws PureException {
    if (logger.isDebugEnabled()) {
      logger.debug("doEditFromTemp...");
    }

    ITeamMgr teamMgr = (ITeamMgr) ArkContentHelper.getContentMgrOf(SRMTypes.TEAM);

    List list = _sTeam.getMemberList();

    teamMgr.saveToTemp(_sTeam, false);
    this.deleteAllMember(_sTeam.getId());
    this.saveMember(_sTeam.getId(), list);

    List deptList = _sTeam.getDeptList();
    this.deleteAllDepts(_sTeam);
    this.saveDepts(_sTeam, deptList);
  }
コード例 #18
0
 private static void update3index() throws PureException {
   IStatement query = null;
   IObjects result = null;
   try {
     int[] aValues = { //
       //            1964,//
       //                    1978, 1979,//
       //                    1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989,//
       1990,
       1991,
       1992,
       1993,
       1994,
       1995,
       1996,
       1997,
       1998,
       1999, //
       2000,
       2001,
       2002,
       2003,
       2004,
       2005,
       2006 //
     };
     IProductMgr mgr = (IProductMgr) ArkContentHelper.getContentMgrOf(Product.class);
     String strSQL =
         "SELECT {this.id},{this.serialNo} FROM {this} WHERE {this.productForm}=3 AND {this.indexIndexDate}=?";
     for (int j = 0; j < aValues.length; j++) {
       query = mgr.createQuery(strSQL, 0);
       query.setInt(0, aValues[j]);
       result = query.executeQuery();
       int i = 1;
       for (Iterator iter = result.iterator(); iter.hasNext(); i++) {
         Product product = (Product) iter.next();
         int nSerialNo = aValues[j] * 1000000 + 300000 + i;
         System.out.println(product.getId() + " : " + nSerialNo);
         product.setProperty("serialNo", nSerialNo);
         mgr.save(product);
       }
     }
   } finally {
     DolphinHelper.clear(result, query);
   }
 }
コード例 #19
0
  public Object convert(
      DolphinObject _old,
      DolphinObject _new,
      String _sFromProperty,
      String _sToProperty,
      ISession _fromSession,
      ISession _toSession,
      EntityMetadata _metadata,
      String _sKey,
      String _sToTable)
      throws PureException {
    // TODO Auto-generated method stub
    int nImportType = Integer.parseInt(_sToProperty);

    // ¼ì²â
    if (Xls2srmForm.JUSTFORCHECK == nImportType) return null;

    String value = _old.getStrProperty(_sFromProperty);
    if (value != null && !"".equals(value.trim())) {
      IUserMgr mgr = (IUserMgr) ArkContentHelper.getContentMgrOf(SRMUser.class);
      SRMUser user = null;
      IObjects users = null;
      IStatement query = null;
      try {
        query =
            mgr.createQuery(
                "SELECT {this.trueName} FROM {this} WHERE {this.employeeSId}=? and {this.name}=? and {this.status}<>32",
                1);
        query.setString(0, value.trim());
        query.setString(1, value.trim());
        users = query.executeQuery(false);
        user = (SRMUser) users.next();
      } finally {
        DolphinHelper.clear(users, query);
      }

      if (user != null) {
        System.out.println("--------------------------------------------");
        System.out.println("TrueName:" + user.getTrueName());
        System.out.println("---------------------------------------------");
        return user.getTrueName();
      }
    }
    return "";
  }
コード例 #20
0
  /**
   * @see com.pureinfo.dolphin.script.function.handler.IFunctionHandler#perform(java.lang.Object[],
   *     com.pureinfo.dolphin.script.execute.IContext)
   */
  public Object perform(Object[] _args, IContext _context) throws PureException {

    int nId = -1;
    try {
      nId = FunctionHandlerUtil.getIntArg(_args, 0, -1);
    } catch (Exception ex) {
      ex.printStackTrace();
      nId = -1;
    }
    if (nId == -1) return new String[] {""};
    IOrganizationMgr mgr = (IOrganizationMgr) ArkContentHelper.getContentMgrOf(Organization.class);
    Organization org = (Organization) mgr.lookupById(nId);
    if (org == null) return new String[] {""};
    String sPath = org.getPath();
    if (sPath == null || sPath.length() < 2) {
      return new String[0];
    }
    return sPath.substring(1).split("\\.");
  }
コード例 #21
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();
   }
 }
コード例 #22
0
  /** @see com.pureinfo.ark.interaction.ActionBase#executeAction() */
  public ActionForward executeAction() throws PureException {
    String[] sIds = request.getParameterValues("id");
    int[] nIds = ActionFormUtil.Strings2Ints(sIds);
    IProductMgr productMgr = (IProductMgr) ArkContentHelper.getContentMgrOf(Product.class);
    Product product = null;
    try {
      for (int i = 0; i <= nIds.length - 1; i++) {
        product = (Product) productMgr.lookupTempById(nIds[i]);
        if (request.getParameter("role") == null) product.setDocSubmitted(true);
        else product.setDocSubmitted(false);
        productMgr.saveToTemp(product, false);
      }
    } finally {
      if (product != null) {
        product.clear();
      }
    }

    request.setAttribute("forward", ProductConstants.PATH_SUCCESS_ALL_PRODUCT_CHECK_LIST_PAGE);
    if (request.getParameter("role") == null) request.setAttribute("message", "选中成果的材料已设置为提交!");
    else request.setAttribute("message", "选中成果的材料已设置为未交!");
    return mapping.findForward("success");
  }
コード例 #23
0
 private int getAuthorId(String _sAuthorName) throws PureException {
   IStatement query = null;
   IObjects result = null;
   try {
     ISRMUserMgr userMgr = (ISRMUserMgr) ArkContentHelper.getContentMgrOf(SRMUser.class);
     // 1. formal table
     String strSQL = "SELECT * FROM {this} WHERE {this.trueName}=?";
     query = userMgr.createQuery(strSQL, 1);
     query.setString(0, _sAuthorName);
     result = query.executeQuery();
     SRMUser user = (SRMUser) result.next();
     if (user != null) return user.getId();
     // 2. temp table
     strSQL = "SELECT * FROM {this}0 WHERE {this.trueName}=?";
     query = userMgr.createQuery(strSQL, 1);
     query.setString(0, _sAuthorName);
     result = query.executeQuery();
     user = (SRMUser) result.next();
     if (user != null) return user.getId();
     return 0;
   } finally {
     DolphinHelper.clear(result, query);
   }
 }
コード例 #24
0
  public DolphinObject next() throws PureException {
    Publication publication = null;
    try {
      String sLine = buffReader.readLine();
      if (sLine == null) {
        clear();
        return null;
      }
      IProductMgr mgr = (IProductMgr) ArkContentHelper.getContentMgrOf(Product.class);
      int i = 0, j = 1;
      String sName, sValue = "", sTemp, sAuthorNames = "";
      while (sLine != null) {
        Product product = new Product();
        sName = sLine.trim();
        if ("题名".equals(sName)) {
          sValue = buffReader.readLine().trim();
        } else {
          sName = buffReader.readLine().trim();
          if ("题名".equals(sName)) {
            sValue = buffReader.readLine().trim();
          } else {
            sName = buffReader.readLine().trim();
            sValue = buffReader.readLine().trim();
          }
        }
        sTemp = buffReader.readLine().trim();
        for (i = 0; !sTemp.equals("作者"); i++) {
          sValue += sTemp;
          sTemp = buffReader.readLine().trim();
        }
        logger.debug("[" + (j++) + "] 题名:" + sValue);
        product.setProductName(sValue);
        sName = sTemp;
        //                sName = buffReader.readLine().trim();
        if (sName.length() == 0) {
          sName = buffReader.readLine().trim();
        }
        if ("作者".equals(sName)) {
          sValue = buffReader.readLine().trim();
          if (sValue.length() > 0) {
            sAuthorNames = sValue.substring(0, sValue.length() - 1);
          } else {
            sAuthorNames = "";
          }
          //                    logger.debug("作者:" + sValue);
        }
        sName = buffReader.readLine().trim();
        if (sName.length() == 0) {
          sName = buffReader.readLine().trim();
        }
        if ("中文关键词".equals(sName)) {
          sValue = buffReader.readLine().trim();
          product.setProperty("chineseKeyWords", sValue);
          //                    logger.debug("中文关键词:" + sValue);
        }
        sName = buffReader.readLine().trim();
        if (sName.length() == 0) {
          sName = buffReader.readLine().trim();
        }
        if ("单位".equals(sName)) {
          sValue = buffReader.readLine().trim();
        }
        sTemp = buffReader.readLine().trim();
        for (i = 0; !sTemp.equals("中文摘要"); i++) {
          sValue += sTemp;
          sTemp = buffReader.readLine().trim();
        }
        //                logger.debug("单位:" + sValue);
        product.setProperty("englishAuthorsDepts", sValue);
        int nPos = sValue.indexOf(",");
        if (nPos == -1) nPos = sValue.indexOf(" ");
        String sFirstAuthorDept = sValue.substring(0, nPos);
        product.setProperty("englishDept", sFirstAuthorDept);
        if (sFirstAuthorDept.indexOf("浙江大学") >= 0) {
          product.setProperty("isZju", true);
        } else {
          product.setProperty("isZju", false);
        }
        //                logger.debug("第一单位:" + sFirstAuthorDept + "; isZju:" +
        // product.getPropertyAsString("isZju"));

        sValue = buffReader.readLine().trim();
        for (i = 0; !sTemp.equals("基金"); i++) {
          sValue += sTemp;
          sTemp = buffReader.readLine().trim();
        }
        if (sValue.endsWith("中文摘要")) {
          sValue = sValue.substring(0, sValue.indexOf("中文摘要"));
        }
        //                logger.debug("中文摘要:" + sValue);
        product.setProperty("abstraction", sValue);

        sValue = buffReader.readLine().trim();
        for (i = 0; !sTemp.equals("刊名"); i++) {
          sValue += sTemp;
          sTemp = buffReader.readLine().trim();
        }
        if (sValue.endsWith("基金")) {
          sValue = sValue.substring(0, sValue.indexOf("基金"));
        }
        //                logger.debug("基金:" + sValue);
        product.setProperty("fund", sValue);

        sValue = buffReader.readLine().trim();
        //                logger.debug("刊名:" + sValue);
        product.setPublicationName(sValue);

        sName = buffReader.readLine().trim();
        if (sName.length() == 0) {
          sName = buffReader.readLine().trim();
        }
        if ("ISSN".equals(sName)) {
          sValue = buffReader.readLine().trim();
          //                    logger.debug("ISSN:" + sValue);
          product.setISSNCode(sValue);
          product.setPublicationId(getPublicationId(sValue));
        }
        sName = buffReader.readLine().trim();
        if (sName.length() == 0) {
          sName = buffReader.readLine().trim();
        }
        int nPublicationYear = 0;
        if ("年".equals(sName)) {
          sValue = buffReader.readLine().trim();
          //                    logger.debug("年:" + sValue);
          nPublicationYear = Integer.parseInt(sValue);
          product.setPublicationYear(nPublicationYear);
        }
        sName = buffReader.readLine().trim();
        if (sName.length() == 0) {
          sName = buffReader.readLine().trim();
        }
        if ("期".equals(sName)) {
          sValue = buffReader.readLine().trim();
          //                    logger.debug("期:" + sValue);
          product.setPublishNo(sValue);
        }
        sName = buffReader.readLine().trim();
        if (sName.length() == 0) {
          sName = buffReader.readLine().trim();
        }
        int nFirstAuthorId = 0;
        if ("第一责任人".equals(sName)) {
          sValue = buffReader.readLine().trim();
          //                    logger.debug("第一责任人:" + sValue);
          if (sValue.length() > 0) {
            sValue = sValue.substring(0, sValue.length() - 1);
            product.setProperty("firstAuthorName", sValue);
            nFirstAuthorId = getAuthorId(sValue);
            if (nFirstAuthorId > 0) {
              product.setProperty("firstAuthorType", 1);
              product.setInsideAuthorId(nFirstAuthorId);
              product.setInsideAuthorNo(1);
            } else {
              product.setProperty("firstAuthorType", 6);
            }
          }
        }
        sLine = buffReader.readLine();
        //                logger.debug("-----------------");

        // 论著编号
        product.setProductForm(ProductConstants.SPRODUCT_FORM_PAPER);
        product.setPublishDate(
            DateTimeUtil.parse(nPublicationYear + "-01-01", ForceConstants.DATE_FORMAT_STR));
        product.setProperty("serialNo", mgr.generateSerialNo(product));
        product.setProperty("isImport", true);
        product.setCreateUser("2006国内论文txt文件");

        String[] arrNames = StrUtil.split(sAuthorNames, ";");
        product.setAuthorsNum(arrNames.length);
        mgr.save(product);

        // --- save authors
        int nProductId = product.getId();
        //                logger.debug("product id : ; " + product.getId());

        IObjUserMappingMgr puMgr =
            (IObjUserMappingMgr) ArkContentHelper.getContentMgrOf(ObjUserMapping.class);
        boolean bFirstInsideAuthor = true;
        for (int k = 0; k < arrNames.length; k++) {
          ObjUserMapping author = new ObjUserMapping();
          int nAuthorId = getAuthorId(arrNames[k]);
          if (nAuthorId > 0) {
            author.setUserType("1");
            author.setUserId(nAuthorId);
            if (nFirstAuthorId == 0 && bFirstInsideAuthor) {
              product.setInsideAuthorId(nAuthorId);
              product.setInsideAuthorNo(k + 1);
              bFirstInsideAuthor = false;
            }
          } else {
            author.setUserType("2");
            author.setUserId(nAuthorId);
          }
          author.setUserName(arrNames[k]);
          author.setOrderNo(k + 1);
          author.setObjId(nProductId);
          author.setObjType(SRMTypes.PRODUCT);
          author.setWeightYear(WeightConstants.WEIGHT_YEAR_DEFAULT_VALUE);
          author.setCreateUser("2006国内论文txt文件");
          puMgr.save(author);
        }
      }
    } catch (IOException ex) {
      logger.error("IOException");
    }
    return publication;
  }
コード例 #25
0
  /**
   * @see com.pureinfo.importer.ref.IImportorRef#convert(com.pureinfo.dolphin.model.DolphinObject,
   *     com.pureinfo.dolphin.model.DolphinObject, java.lang.String, java.lang.String,
   *     com.pureinfo.dolphin.persister.ISession, com.pureinfo.dolphin.persister.ISession,
   *     com.pureinfo.dolphin.mapping.EntityMetadata, java.lang.String, java.lang.String)
   */
  public Object convert(
      DolphinObject _old,
      DolphinObject _new,
      String _sFromProperty,
      String _sToProperty,
      ISession _fromSession,
      ISession _toSession,
      EntityMetadata _metadata,
      String _sKey,
      String _sToTable)
      throws PureException {
    String sAdminName = _old.getStrProperty(_sFromProperty);
    if (sAdminName == null) return null;
    String sDeptCode = _old.getStrProperty("单位代码");
    _new.setProperty("firstAuthorName", sAdminName);

    IObjects users = null;
    IStatement query = null;
    SRMUser user = null;
    int nUserId = 0;
    try {
      ISRMUserMgr userMgr = (ISRMUserMgr) ArkContentHelper.getContentMgrOf(SRMUser.class);
      query =
          userMgr.createQuery(
              "SELECT * FROM {this} WHERE {this.trueName}=?", DolphinConstants.MAXSIZE_UNLIMITED);
      query.setString(0, sAdminName);
      users = query.executeQuery();
      SRMUser[] aUsers = (SRMUser[]) users.toList().toArray(new SRMUser[0]);
      if (aUsers.length == 0) {
        nUserId = 0;
      } else if (aUsers.length == 1) {
        user = aUsers[0];
        nUserId = user.getId();
      } else {
        if (sDeptCode == null) {
          sDeptCode = _old.getStrProperty("字段1");
        }
        String sCollege = sDeptCode.substring(0, 2);
        for (int i = 0; i < aUsers.length; i++) {
          Organization org = aUsers[i].getDepartment();
          String sCode = null;
          if (org != null) sCode = org.getCode();
          if (sCode != null && sCode.length() > 2) sCode = sCode.substring(0, 2);
          if (sCode != null && sCode.equals(sCollege)) {
            user = aUsers[i];
            nUserId = user.getId();
            break;
          }
        }
        if (user == null) {
          logger.error(_old.getStrProperty("成果名称") + "," + _old.getStrProperty("负责人"));
          user = aUsers[0];
          nUserId = user.getId();
        }
      }
      LocalContextHelper.currentSession().autoGenerateProperty(_new, "id");
      int nProductId = _new.getIntProperty("id", -1);
      ObjUserMapping author = new ObjUserMapping();

      author.setObjType(SRMTypes.PRODUCT);
      author.setUserType("1");
      author.setUserId(nUserId);
      author.setUserName(sAdminName);
      author.setOrderNo(1);
      author.setObjId(nProductId);
      author.setWeightYear(WeightConstants.WEIGHT_YEAR_DEFAULT_VALUE);

      IObjUserMappingMgr puMgr =
          (IObjUserMappingMgr) ArkContentHelper.getContentMgrOf(ObjUserMapping.class);
      puMgr.save(author);
    } finally {
      DolphinHelper.clear(users, query);
    }
    return "" + nUserId;
  }
コード例 #26
0
 private void deleteAllDepts(ArkContent _obj) throws PureException {
   IObjDeptMappingMgr mgr =
       (IObjDeptMappingMgr) ArkContentHelper.getContentMgrOf(SRMTypes.OBJ_DEPT_MAPPING);
   mgr.deleteAllOfObj(_obj.getArkType(), _obj.getId());
 }
コード例 #27
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();
    }
  }
コード例 #28
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();
 }