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); } }
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); }
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); } }
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); } }
/** @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"); }
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; }