List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:regresiones.RegresionMultiple.java
private XYDataset createSampleDataset(Double[] estimada, Integer opcion) { XYSeries series1 = new XYSeries("X - Y"); for (Double[] dato : datos) { if (opcion.equals(1)) { series1.add(dato[0], dato[2]); } else {/*from w ww . j ava 2 s. co m*/ series1.add(dato[1], dato[2]); } } XYSeries series2 = new XYSeries("X - Y estimada"); for (int i = 0; i < datos.length; i++) { if (opcion.equals(1)) series2.add(datos[i][0], estimada[i]); else series2.add(datos[i][1], estimada[i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); return dataset; }
From source file:net.firejack.platform.service.registry.helper.PackageVersionHelper.java
/** * @param packageRN//from w ww . j a v a2 s .c o m * @return */ public List<PackageVersionInfo> populatePackageVersionInfo(PackageModel packageRN) throws IOException { List<PackageVersionInfo> packageVersionInfos = new ArrayList<PackageVersionInfo>(); ServiceResponse<FileInfo> search = OPFEngine.FileStoreService.search(OpenFlame.FILESTORE_BASE, "\\d+", helper.getVersion(), packageRN.getId().toString()); List<FileInfo> data = search.getData(); FileInfo[] packageVersionFolders = data.toArray(new FileInfo[data.size()]); packageVersionFolders = sortingByNameLikeNumber(packageVersionFolders, false); for (FileInfo folder : packageVersionFolders) { String versionNumber = folder.getFilename(); Integer version = Integer.parseInt(versionNumber); String versionName = VersionUtils.convertToVersion(version); PackageVersionInfo packageVersionInfo = new PackageVersionInfo(versionName, version); packageVersionInfo.setCurrent(version.equals(packageRN.getVersion())); packageVersionInfos.add(packageVersionInfo); } return packageVersionInfos; }
From source file:com.aurel.track.item.ItemBL.java
public static ItemLocationForm getItemLocationFixedIssueType(Locale locale, TPersonBean user, Integer defaultProjectID, Integer issueTypeID) { ItemLocationForm form = new ItemLocationForm(); Integer projectID = null;/*ww w . j ava 2 s . c om*/ Integer personID = user.getObjectID(); TWorkItemBean defaultWorkItemBean = ItemBL.loadLastCreated(personID); //projectID if (defaultProjectID == null && defaultWorkItemBean != null) { defaultProjectID = defaultWorkItemBean.getProjectID(); } List<TreeNode> projectTree = ProjectBL.loadProjectsWithCreateIssueRightForItemType(personID, issueTypeID); form.setProjectTree(projectTree); if (projectTree == null || projectTree.isEmpty()) { return null; } List<Integer> projectIDs = ProjectBL.getProjectIDsFromTree(projectTree); if (defaultProjectID != null) { Iterator<Integer> iterator = projectIDs.iterator(); while (iterator.hasNext()) { Integer projectIDCrt = iterator.next(); if (projectIDCrt.equals(defaultProjectID)) { projectID = defaultProjectID; break; } } } if (projectID == null && !projectIDs.isEmpty()) { projectID = projectIDs.get(0); } form.setProjectID(projectID); form.setIssueTypeID(issueTypeID); List<IntegerStringBean> fixedList = new ArrayList<IntegerStringBean>(); TListTypeBean listTypeBean = LookupContainer.getItemTypeBean(issueTypeID, locale); String localizedTex = listTypeBean.getLabel(); fixedList.add(new IntegerStringBean(localizedTex, listTypeBean.getObjectID())); form.setIssueTypeList(fixedList); form.setFixedIssueType(true); updateItemLocationFormLabels(form, locale, projectID, issueTypeID, user); return form; }
From source file:org.openmrs.module.laboratory.web.ajax.AjaxController.java
/** * Accept a test// ww w .ja v a 2s .co m * * @param orderId * @param model * @return id of accepted laboratory test */ @RequestMapping(value = "/module/laboratory/ajax/acceptTest.htm", method = RequestMethod.GET) public String acceptTest(@RequestParam("orderId") Integer orderId, @RequestParam("date") String dateStr, @RequestParam("sampleId") String sampleId, Model model) { Order order = Context.getOrderService().getOrder(orderId); if (order != null) { try { LaboratoryService ls = (LaboratoryService) Context.getService(LaboratoryService.class); Integer acceptedTestId = ls.acceptTest(order, sampleId); model.addAttribute("acceptedTestId", acceptedTestId); if (acceptedTestId > 0) { model.addAttribute("status", "success"); } else { model.addAttribute("status", "fail"); if (acceptedTestId.equals(LaboratoryConstants.ACCEPT_TEST_RETURN_ERROR_EXISTING_SAMPLEID)) { model.addAttribute("error", "Existing sample id found"); } else if (acceptedTestId == LaboratoryConstants.ACCEPT_TEST_RETURN_ERROR_EXISTING_TEST) { model.addAttribute("error", "Existing accepted test found"); } } } catch (Exception e) { model.addAttribute("acceptedTestId", "0"); } } return "/module/laboratory/ajax/acceptTest"; }
From source file:com.adobe.cq.wcm.core.components.internal.servlets.AdaptiveImageServlet.java
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { try {/*from w ww. jav a2 s.c o m*/ String[] selectors = request.getRequestPathInfo().getSelectors(); if (selectors.length != 1 && selectors.length != 2) { LOGGER.error("Expected 1 or 2 selectors, instead got: {}.", Arrays.toString(selectors)); response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } Resource imageResource = request.getResource(); Image image = new Image(imageResource); if (!image.hasContent()) { LOGGER.error("The image from {} does not have a valid file reference.", imageResource.getPath()); response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if ("image/gif".equals(getImageType(request.getRequestPathInfo().getExtension()))) { if (checkModifiedSince(request, response)) { return; } else { response.setContentType("image/gif"); try { String fileReference = image.getFileReference(); if (StringUtils.isNotEmpty(fileReference)) { String damOriginalRendition = fileReference + "/jcr:content/renditions/original"; response.getOutputStream().write(IOUtils.toByteArray(request.getResourceResolver() .getResource(damOriginalRendition).adaptTo(InputStream.class))); } else { response.getOutputStream() .write(IOUtils.toByteArray(image.getData().getBinary().getStream())); } return; } catch (Exception e) { LOGGER.error("Cannot write GIF image stream.", e); response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } } } String widthSelector = selectors[selectors.length - 1]; if (!DEFAULT_SELECTOR.equals(widthSelector)) { try { Integer width = Integer.parseInt(widthSelector); boolean isRequestedWidthAllowed = false; for (Integer allowedWidth : getAllowedRenditionWidths(request)) { if (width.equals(allowedWidth)) { isRequestedWidthAllowed = true; break; } } if (isRequestedWidthAllowed) { LOGGER.debug("The image was requested with a {}px width. Resizing.", width); threadLocalWidthSelector.set(width); } else { LOGGER.error("The requested width ({}) is not allowed by the content policy.", width); response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } } catch (NumberFormatException e) { LOGGER.error("The requested width ({}) is not a valid Integer.", widthSelector); response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } } else { List<Integer> allowedRenditionWidths = getAllowedRenditionWidths(request); if (!allowedRenditionWidths.isEmpty()) { // resize to the first value of the allowedRenditionWidths int size = allowedRenditionWidths.get(0); LOGGER.debug( "The image request contains no width information, but the image's content policy defines at least one " + "allowed width. Will resize the image to the first allowed width - {}px.", size); threadLocalWidthSelector.set(size); } else { // resize to the default value LOGGER.debug( "The image request contains no width information and there's no information about the allowed widths in " + "the image's content policy. Will resize the image to {}px.", defaultResizeWidth); threadLocalWidthSelector.set(defaultResizeWidth); } } super.doGet(request, response); } finally { threadLocalWidthSelector.remove(); } }
From source file:com.evolveum.midpoint.test.util.Lsof.java
private void diff(StringBuilder sb, String key, Integer baselineValue, Integer currentValue) { if (baselineValue == null) { baselineValue = 0;//from ww w. j a v a 2 s . c om } if (currentValue == null) { currentValue = 0; } if (baselineValue.equals(currentValue)) { return; } sb.append(key).append(": "); int diff = currentValue - baselineValue; if (diff > 0) { sb.append("+").append(diff); } else { sb.append(diff); } sb.append("\n"); }
From source file:org.uaa.admin.resource.Roles.java
@POST @Path("/assign_auth") @Produces(MediaType.APPLICATION_JSON)//w w w . j a va 2 s.com @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public String assignAuthorities(@FormParam("role_id") Integer role_id, @FormParam("auth_ids") String auth_ids, @FormParam("mod_id") Integer mod_id) { request = uriInfo.getRequestUri().toString(); if (role_id == null || role_id.equals("")) { String error_msg = String.format(ConfigUtil.getValue("10010"), "role_id"); ResponseWithStatus response = new ResponseWithStatus(request, "10010", error_msg); return response.toJson(); } if (mod_id == null || mod_id.equals("")) { String error_msg = String.format(ConfigUtil.getValue("10010"), "mod_id"); ResponseWithStatus response = new ResponseWithStatus(request, "10010", error_msg); return response.toJson(); } if (auth_ids == null) { String error_msg = String.format(ConfigUtil.getValue("10010"), "auth_ids"); ResponseWithStatus response = new ResponseWithStatus(request, "10010", error_msg); return response.toJson(); } // auth_ids??? if (auth_ids.equals("")) { roleAuthorityService.deleteAuthorities(role_id, mod_id); roleModuleService.deleteRoleModule(role_id, mod_id); } else { String[] ids = auth_ids.split(","); List<Integer> auths = new ArrayList<Integer>(); for (String id : ids) { if (id.equals("")) continue; auths.add(Integer.parseInt(id)); } roleAuthorityService.assignAuthorities(role_id, mod_id, auths); //???? RoleModule tmpRoleMod = roleModuleService.queryRoleModule(role_id, mod_id); if (tmpRoleMod == null) { roleModuleService.assignRoleModule(role_id, mod_id); } //????? Module mod = moduleService.queryModuleById(mod_id); RoleModule tmpRoleMod1 = roleModuleService.queryRoleModule(role_id, mod.getFather_mod()); if (tmpRoleMod1 == null) { roleModuleService.assignRoleModule(role_id, mod.getFather_mod()); } } ResponseWithStatus response = new ResponseWithStatus(request, "10000", "Assign Authorities And Modules Successfully"); return response.toJson(); }
From source file:edu.ku.brc.specify.conversion.CollectionInfo.java
/** * @param oldDBConn/*from www. j av a 2 s. c o m*/ * @return */ public static Vector<CollectionInfo> getCollectionInfoList(final Connection oldDBConn, final boolean doSkipCheck) { //collectionInfoList.clear(); if (collectionInfoList.isEmpty()) { String hostTaxonID = "SELECT Count(tn.TaxonomicUnitTypeID) FROM habitat h " + "INNER JOIN taxonname tn ON h.HostTaxonID = tn.TaxonNameID WHERE tn.TaxonomyTypeId = "; /*String sql = "SELECT cot.CollectionObjectTypeID, cot.CollectionObjectTypeName, csd.CatalogSeriesDefinitionID, csd.CatalogSeriesID FROM collectionobjecttype cot " + "INNER JOIN catalogseriesdefinition csd on " + "csd.ObjectTypeId = cot.CollectionObjectTypeId WHERE cot.Category = 'Biological' ORDER BY cot.CollectionObjectTypeID, csd.CatalogSeriesID"; */ String catSeriesSQL = "SELECT SeriesName, CatalogSeriesPrefix, Remarks, LastEditedBy FROM catalogseries WHERE CatalogSeriesID = "; String cntTaxonName = "SELECT COUNT(TaxonNameID) FROM taxonname WHERE TaxonName IS NOT NULL AND TaxonomyTypeId = "; String colObjCountPerCatSeriesSQL = "SELECT COUNT(cc.CatalogSeriesID) " + //, cc.CatalogSeriesID, cs.SeriesName " + "FROM collectionobjectcatalog cc INNER JOIN catalogseries cs ON cc.CatalogSeriesID = cs.CatalogSeriesID " + "WHERE cs.CatalogSeriesID = %d GROUP BY cs.CatalogSeriesID"; String colObjDetCountPerCatSeriesSQL = "SELECT COUNT(cc.CatalogSeriesID) " + "FROM determination d INNER JOIN collectionobject co ON d.BiologicalObjectID = co.CollectionObjectID " + "INNER JOIN collectionobjectcatalog cc ON co.CollectionObjectID = cc.CollectionObjectCatalogID " + "WHERE cc.CatalogSeriesID = %d AND d.TaxonNameID IS NOT NULL GROUP BY cc.CatalogSeriesID"; String colObjCatSeriesSQL = "SELECT cot.CollectionObjectTypeID, cot.CollectionObjectTypeName, csd.CatalogSeriesDefinitionID, csd.CatalogSeriesID FROM collectionobjecttype cot " + "INNER JOIN catalogseriesdefinition csd on csd.ObjectTypeId = cot.CollectionObjectTypeId " + "WHERE cot.Category = 'Biological' ORDER BY cot.CollectionObjectTypeID, csd.CatalogSeriesID"; Statement stmt = null; try { pw = new PrintWriter(String.format("sql_%d.log", pwPassCnt++)); log.debug(colObjCatSeriesSQL); logSQL("ColObj Cat Series", colObjCatSeriesSQL); HashSet<Integer> taxonTypeIdHash = new HashSet<Integer>(); stmt = oldDBConn.createStatement(); ResultSet rs = stmt.executeQuery(colObjCatSeriesSQL); while (rs.next()) { CollectionInfo info = new CollectionInfo(oldDBConn); Integer colObjTypeID = rs.getInt(1); pw.println(String.format( "%d ================================================================================", colObjTypeID)); System.err.println("ColObjType: " + colObjTypeID); info.setColObjTypeId(colObjTypeID); info.setColObjTypeName(rs.getString(2)); info.setCatSeriesDefId(rs.getInt(3)); info.setCatSeriesId(rs.getInt(4)); String sql = String.format(colObjCountPerCatSeriesSQL, info.getCatSeriesId()); log.debug(sql); logSQL("ColObj Count Per Cat Series", sql); int colObjCnt = BasicSQLUtils.getCountAsInt(oldDBConn, sql); info.setColObjCnt(colObjCnt); sql = String.format(colObjDetCountPerCatSeriesSQL, info.getCatSeriesId()); log.debug(sql); logSQL("ColObj Count Determinations Per Cat Series", sql); info.setColObjDetTaxCnt(BasicSQLUtils.getCountAsInt(oldDBConn, sql)); sql = catSeriesSQL + info.getCatSeriesId(); log.debug(sql); logSQL("Cat Series", sql); Vector<Object[]> rows = BasicSQLUtils.query(oldDBConn, sql); if (rows != null && rows.size() == 1) { Object[] row = rows.get(0); info.setCatSeriesName((String) row[0]); info.setCatSeriesPrefix((String) row[1]); info.setCatSeriesRemarks((String) row[2]); info.setCatSeriesLastEditedBy((String) row[3]); } else { log.error("Error getting CollectionInfo for CollectionObjectTypeID: " + rs.getInt(1) + " number of CatlogSeries: " + rows.size()); } if (!doSkipCheck) { String detSQLStr = "SELECT ct.TaxonomyTypeID, (select distinct relatedsubtypevalues FROM usysmetacontrol c " + "LEFT JOIN usysmetafieldsetsubtype fst ON fst.fieldsetsubtypeid = c.fieldsetsubtypeid " + "WHERE objectid = 10290 AND ct.taxonomytypeid = c.relatedsubtypevalues) AS DeterminationTaxonType " + "FROM collectiontaxonomytypes ct WHERE ct.biologicalobjecttypeid = " + info.getColObjTypeId(); log.debug(detSQLStr); logSQL("Checking USYS data", detSQLStr); Vector<Object[]> detRows = BasicSQLUtils.query(oldDBConn, detSQLStr); for (Object[] row : detRows) { Integer txnTypeId = (Integer) row[0]; String detTxnTypes = (String) row[1]; if (detTxnTypes == null) { detTxnTypes = Integer.toString(txnTypeId); } if (StringUtils.isNotEmpty(detTxnTypes)) { String txNameSQL = "SELECT TaxonomyTypeName FROM taxonomytype WHERE TaxonomyTypeID = "; logSQL("Getting Taxon Type Name", txNameSQL + txnTypeId); if (StringUtils.contains(detTxnTypes, ',')) { StringBuilder sb = new StringBuilder(); String[] toks = StringUtils.split(detTxnTypes, ','); String dtName = BasicSQLUtils.querySingleObj(oldDBConn, txNameSQL + txnTypeId); sb.append(String.format( "Warning - There are %d DeterminationTaxonTypes for TaxonObjectType %d (%s) they are:\n", toks.length, txnTypeId, dtName)); for (String id : toks) { logSQL("Getting Taxon Type Name", txNameSQL + id); String name = BasicSQLUtils.querySingleObj(oldDBConn, txNameSQL + id); sb.append(id); sb.append(" - "); sb.append(name); sb.append("\n"); } sb.append( "\nThis database will need to be fixed by hand before it can be converted."); UIRegistry.showError(sb.toString()); System.exit(0); askForFix = true; return null; } else if (StringUtils.isNumeric(detTxnTypes.trim())) { Integer txnType = Integer.parseInt(detTxnTypes); if (!txnType.equals(txnTypeId)) { String tName = BasicSQLUtils.querySingleObj(oldDBConn, txNameSQL + txnType); String dtName = BasicSQLUtils.querySingleObj(oldDBConn, txNameSQL + txnTypeId); StringBuilder sb = new StringBuilder(); sb.append(String.format( "Warning - The TaxonObjectType %d (%s) in the DeterminationTaxonTypes field\ndoesn't match the actual TaxonObjectType %d (%s)", txnType, tName, txnTypeId, dtName)); UIRegistry.showError(sb.toString()); askForFix = true; return null; } } } } } /*info.setDeterminationTaxonType(detTxnTypeStr); for (Integer id : info.getDetTaxonTypeIdList()) { log.debug("ID: "+id); }*/ // This represents a mapping from what would be the Discipline (Biological Object Type) to the Taxonomic Root sql = String.format( "SELECT tt.TaxonomyTypeID, tt.TaxonomyTypeName, tt.KingdomID, tn.TaxonNameID, tn.TaxonName, tu.TaxonomicUnitTypeID FROM taxonomytype AS tt " + "INNER JOIN taxonomicunittype AS tu ON tt.TaxonomyTypeID = tu.TaxonomyTypeID " + "INNER JOIN taxonname AS tn ON tu.TaxonomyTypeID = tn.TaxonomyTypeID " + "INNER JOIN collectiontaxonomytypes AS ct ON tn.TaxonomyTypeID = ct.TaxonomyTypeID " + "WHERE tu.RankID = 0 AND tn.RankID = 0 AND ct.BiologicalObjectTypeID = %d " + "ORDER BY ct.BiologicalObjectTypeID ASC", info.getColObjTypeId()); log.debug(sql); logSQL("Taxon -> Coll Taxon Types", sql); rows = BasicSQLUtils.query(oldDBConn, sql); if (rows != null) { Object[] row = rows.get(0); int taxonomyTypeID = (Integer) row[0]; info.setTaxonomyTypeId(taxonomyTypeID); info.setTaxonomyTypeName((String) row[1]); info.setKingdomId((Integer) row[2]); info.setTaxonNameId((Integer) row[3]); info.setTaxonName((String) row[4]); info.setTaxonomicUnitTypeID((Integer) row[5]); info.setTaxonNameCnt(BasicSQLUtils.getCountAsInt(oldDBConn, cntTaxonName + taxonomyTypeID)); log.debug("TaxonomyTypeName: " + info.getTaxonomyTypeName() + " TaxonName: " + info.getTaxonName() + " TaxonomyTypeId: " + info.getTaxonomyTypeId()); sql = hostTaxonID + taxonomyTypeID; log.debug(sql); Vector<Object> ttNames = BasicSQLUtils.querySingleCol(oldDBConn, sql); if (ttNames != null && ttNames.size() > 0 && ((Long) ttNames.get(0)) > 0) { info.setSrcHostTaxonCnt((Long) ttNames.get(0)); } else { info.setSrcHostTaxonCnt(0); } taxonTypeIdHash.add(taxonomyTypeID); } else { log.error("Error getting CollectionInfo for CollectionObjectTypeID: " + rs.getInt(1)); } collectionInfoList.add(info); //System.out.println(info.toString()); } rs.close(); // Here we figure out whether a Taxon Tree that is used by HostTaxonID is associated with a Collection. String sql = "SELECT DISTINCT tt.TaxonomyTypeID, tt.TaxonomyTypeName FROM habitat AS h " + "INNER JOIN taxonname AS tn ON h.HostTaxonID = tn.TaxonNameID " + "INNER JOIN taxonomytype AS tt ON tn.TaxonomyTypeID = tt.TaxonomyTypeID"; logSQL("Check for HostID", sql); Vector<Integer> txTypeIds = BasicSQLUtils.queryForInts(oldDBConn, sql); HashSet<Integer> txnTypeIdHashSet = new HashSet<Integer>(); for (Integer txTypId : txTypeIds) { Boolean hasColInfo = false; for (CollectionInfo colInfo : collectionInfoList) { if (colInfo.getTaxonomyTypeId().equals(txTypId)) { hasColInfo = true; } } if (!hasColInfo) { txnTypeIdHashSet.add(txTypId); } } // These TaxonTypeIds do not have CollectionInfo for (Iterator<Integer> iter = txnTypeIdHashSet.iterator(); iter.hasNext();) { Integer taxonomyTypeID = iter.next(); System.out.println(taxonomyTypeID); sql = "SELECT tt.TaxonomyTypeName, tn.TaxonName, tt.KingdomID, tn.TaxonNameID, tn.TaxonomicUnitTypeID FROM taxonomytype AS tt " + "INNER JOIN taxonomicunittype AS tut ON tt.TaxonomyTypeID = tut.TaxonomyTypeID " + "INNER JOIN taxonname AS tn ON tt.TaxonomyTypeID = tn.TaxonomyTypeID AND tut.TaxonomicUnitTypeID = tn.TaxonomicUnitTypeID " + "WHERE tt.TaxonomyTypeID = " + taxonomyTypeID + " AND tn.RankID = 0"; log.debug(sql); logSQL("Get TaxonTypeName etc from TaxonomyTypeID and RankID = 0", sql); Vector<Object[]> rows = BasicSQLUtils.query(oldDBConn, sql); if (rows.size() != 1) { String msg = "There should only be '1' TaxonTypeName for TaxonomyTypeID:" + taxonomyTypeID; log.error(msg); UIRegistry.showError(msg); continue; } CollectionInfo colInfo = new CollectionInfo(oldDBConn); String taxonTypeName = (String) rows.get(0)[0]; String taxonRootName = (String) rows.get(0)[1]; if (StringUtils.isEmpty(taxonRootName)) { taxonRootName = taxonTypeName; } //colInfo.setColObjTypeId(); colInfo.setColObjTypeName(taxonRootName); //colInfo.setCatSeriesDefId(rs.getInt(3)); //colInfo.setCatSeriesId(rs.getInt(4)); colInfo.setCatSeriesName(taxonRootName); colInfo.setCatSeriesPrefix(""); colInfo.setCatSeriesRemarks(""); colInfo.setCatSeriesLastEditedBy(""); colInfo.setColObjCnt(1); colInfo.setColObjDetTaxCnt(1); colInfo.setTaxonomyTypeId(taxonomyTypeID); colInfo.setTaxonomyTypeName(taxonTypeName); colInfo.setKingdomId((Integer) rows.get(0)[2]); colInfo.setTaxonNameId((Integer) rows.get(0)[3]); colInfo.setTaxonName(taxonRootName); colInfo.setTaxonomicUnitTypeID((Integer) rows.get(0)[4]); colInfo.setTaxonNameCnt(BasicSQLUtils.getCountAsInt(oldDBConn, cntTaxonName + taxonomyTypeID)); colInfo.setSrcHostTaxonCnt(0); collectionInfoList.add(colInfo); } // Do All /*String sqlAllTx = "SELECT cot.CollectionObjectTypeID, cot.CollectionObjectTypeName, tt.TaxonomyTypeID, tt.TaxonomyTypeName, tt.KingdomID, tn.TaxonNameID, tn.TaxonName, tn.TaxonomicUnitTypeID " + "FROM collectionobjecttype AS cot " + "INNER JOIN collectiontaxonomytypes as ctt ON cot.CollectionObjectTypeID = ctt.BiologicalObjectTypeID " + "INNER JOIN taxonomytype as tt ON ctt.TaxonomyTypeID = tt.TaxonomyTypeID " + "INNER JOIN taxonname as tn ON tt.TaxonomyTypeID = tn.TaxonomyTypeID " + "WHERE cot.Category = 'Biological' AND tn.ParentTaxonNameID IS NULL"; log.debug(sqlAllTx); Vector<Object[]> rows = BasicSQLUtils.query(oldDBConn, sqlAllTx); for (Object[] row : rows) { int taxonomyTypeID = (Integer)row[2]; if (taxonTypeIdHash.get(taxonomyTypeID) == null) { CollectionInfo info = new CollectionInfo(oldDBConn); info.setColObjTypeId((Integer)row[0]); info.setColObjTypeName((String)row[1]); info.setCatSeriesDefId(null); info.setCatSeriesId(null); info.setCatSeriesName(""); info.setCatSeriesPrefix(""); info.setCatSeriesRemarks(""); info.setCatSeriesLastEditedBy(""); info.setTaxonomyTypeId(taxonomyTypeID); info.setTaxonomyTypeName((String)row[3]); info.setKingdomId((Integer)row[4]); info.setTaxonNameId((Integer)row[5]); info.setTaxonName((String)row[6]); info.setTaxonomicUnitTypeID((Integer)row[7]); info.setTaxonNameCnt(BasicSQLUtils.getCountAsInt(oldDBConn, cntTaxonName + taxonomyTypeID)); Vector<Object> ttNames = BasicSQLUtils.querySingleCol(oldDBConn, hostTaxonID + taxonomyTypeID); if (ttNames != null && ttNames.size() > 0 && ((Long)ttNames.get(0)) > 0) { info.setSrcHostTaxonCnt((Long)ttNames.get(0)); } else { info.setSrcHostTaxonCnt(0); } taxonTypeIdHash.put(taxonomyTypeID, true); collectionInfoList.add(info); } }*/ dump(); } catch (Exception ex) { ex.printStackTrace(); try { if (stmt != null) { stmt.close(); } } catch (Exception e) { } } finally { if (pw != null) pw.close(); } } Collections.sort(collectionInfoList); return collectionInfoList; }
From source file:backend.facades.UserController.java
public UserEntity getUserById(Long id) { UserEntity userEntity = null;//from w w w . j a v a 2 s .com BasicDBObject query = new BasicDBObject(); query.put("_id", id); DBCursor cursor = userCollection.find(query); try { if (cursor.count() > 0) { DBObject document = cursor.next(); userEntity = new UserEntity(); userEntity.setId((Long) document.get("_id")); userEntity.setUsername((String) document.get("username")); userEntity.setEmail((String) document.get("email")); userEntity.setFirstname((String) document.get("firstname")); userEntity.setPasswd((String) document.get("passwd")); userEntity.setLastname((String) document.get("lastname")); userEntity.setStatus((Integer) document.get("status")); userEntity.setImageId((String) document.get("imageId")); userEntity.setRegisteredDate((Date) document.get("registeredDate")); userEntity.setLastLoginDate((Date) document.get("lastLoginDate")); userEntity.setLanguageCode((String) document.get("languageCode")); userEntity.setUserRole((Integer) document.get("userRole")); userEntity.setModeratorValue((Integer) document.get("moderator")); Integer value = (Integer) document.get("subscribe"); userEntity.setPersonalWebPage((String) document.get("webpage")); if (value != null && value.equals(StatusTypes.ACCEPT_SUBSCRB)) { userEntity.setAcceptSubscr(true); } else { userEntity.setAcceptSubscr(false); } } } finally { cursor.close(); } return userEntity; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.EDSF424SupplementV1_1Generator.java
/** * /*from w w w. j ava2 s . c o m*/ * This method returns EDSF424SupplementDocument object based on proposal * development document which contains the EDSF424SupplementDocument * informations * NoviceApplicant,HumanResearch,HumanResearchExempt,ExemptionsNumber,AssuranceNumber,and * attachment for a particular proposal * * @return edsf424SupplementDocument(EDSF424SupplementDocument) * {@link XmlObject} of type EDSF424SupplementDocument. */ private EDSF424SupplementDocument getEDSF424Supplement() { EDSF424SupplementDocument edsf424SupplementDocument = EDSF424SupplementDocument.Factory.newInstance(); EDSF424Supplement edsf424Supplement = EDSF424Supplement.Factory.newInstance(); edsf424Supplement.setFormVersion(FormVersion.v1_1.getVersion()); ProposalPersonContract pi = getS2SProposalPersonService().getPrincipalInvestigator(pdDoc); edsf424Supplement.setProjectDirector(globLibV20Generator.getContactPersonDataType(pi)); String answer = null; List<? extends AnswerHeaderContract> answerHeaders = getPropDevQuestionAnswerService() .getQuestionnaireAnswerHeaders(pdDoc.getDevelopmentProposal().getProposalNumber()); if (answerHeaders != null && !answerHeaders.isEmpty()) { for (AnswerHeaderContract answerHeader : answerHeaders) { List<? extends AnswerContract> answerDetails = answerHeader.getAnswers(); for (AnswerContract answers : answerDetails) { Integer seqId = getQuestionAnswerService().findQuestionById(answers.getQuestionId()) .getQuestionSeqId(); if (seqId != null && seqId.equals(PROPOSAL_YNQ_NOVICE_APPLICANT)) { if (answers.getAnswer() != null) { answer = answers.getAnswer(); } if (YnqConstant.YES.code().equals(answer)) { edsf424Supplement.setIsNoviceApplicant(YesNoNotApplicableDataType.Y_YES); } else if (YnqConstant.NO.code().equals(answer)) { edsf424Supplement.setIsNoviceApplicant(YesNoNotApplicableDataType.N_NO); } else if (YnqConstant.NA.code().equals(answer)) { edsf424Supplement.setIsNoviceApplicant(YesNoNotApplicableDataType.NA_NOT_APPLICABLE); } } } } } edsf424Supplement.setIsHumanResearch(YesNoDataType.N_NO); OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization(); for (ProposalSpecialReviewContract specialReview : pdDoc.getDevelopmentProposal().getPropSpecialReviews()) { if (specialReview.getSpecialReviewType() != null && specialReview.getSpecialReviewType().getCode().equals(SPECIAL_REVIEW_CODE)) { edsf424Supplement.setIsHumanResearch(YesNoDataType.Y_YES); if (specialReview.getApprovalType() != null && specialReview.getApprovalType().getCode().equals(APPROVAL_TYPE_CODE)) { edsf424Supplement.setIsHumanResearchExempt(YesNoDataType.Y_YES); ExemptionsNumber exemptionsNumber = ExemptionsNumber.Factory.newInstance(); exemptionsNumber.setIsHumanResearchExempt(YesNoDataType.Y_YES); if (specialReview.getSpecialReviewExemptions() != null && specialReview.getSpecialReviewExemptions().size() > 0) { List<String> exemptionTypeCodes = new ArrayList<>(); for (ProposalSpecialReviewExemptionContract exemption : specialReview .getSpecialReviewExemptions()) { exemptionTypeCodes.add(exemption.getExemptionType().getCode()); } exemptionsNumber.setStringValue(colToString(exemptionTypeCodes)); } edsf424Supplement.setExemptionsNumber(exemptionsNumber); } else { edsf424Supplement.setIsHumanResearchExempt(YesNoDataType.N_NO); if (organization != null) { AssuranceNumber assuranceNumber = AssuranceNumber.Factory.newInstance(); assuranceNumber.setIsHumanResearchExempt(YesNoDataType.N_NO); if (organization.getHumanSubAssurance() != null) { assuranceNumber.setStringValue(organization.getHumanSubAssurance()); } edsf424Supplement.setAssuranceNumber(assuranceNumber); } } Boolean paramValue = s2SConfigurationService.getValueAsBoolean( ConfigurationConstants.IRB_PROTOCOL_DEVELOPMENT_PROPOSAL_LINKING_ENABLED); if (paramValue) { ExemptionsNumber exemptionsNumber = ExemptionsNumber.Factory.newInstance(); if (specialReview.getSpecialReviewExemptions() != null && specialReview.getSpecialReviewExemptions().size() > 0) { edsf424Supplement.setIsHumanResearchExempt(YesNoDataType.Y_YES); exemptionsNumber.setIsHumanResearchExempt(YesNoDataType.Y_YES); List<String> exemptionTypeCodes = new ArrayList<>(); for (ProposalSpecialReviewExemptionContract exemption : specialReview .getSpecialReviewExemptions()) { exemptionTypeCodes.add(exemption.getExemptionType().getCode()); } exemptionsNumber.setStringValue(colToString(exemptionTypeCodes)); edsf424Supplement.setExemptionsNumber(exemptionsNumber); } else { edsf424Supplement.setIsHumanResearch(YesNoDataType.N_NO); if (organization != null) { AssuranceNumber assuranceNumber = AssuranceNumber.Factory.newInstance(); assuranceNumber.setIsHumanResearchExempt(YesNoDataType.N_NO); if (organization.getHumanSubAssurance() != null) { assuranceNumber.setStringValue(organization.getHumanSubAssurance()); } edsf424Supplement.setAssuranceNumber(assuranceNumber); } } } break; } else { edsf424Supplement.setIsHumanResearch(YesNoDataType.N_NO); } } AttachedFileDataType attachedFileDataType = null; for (NarrativeContract narrative : pdDoc.getDevelopmentProposal().getNarratives()) { if (narrative.getNarrativeType().getCode() != null && Integer .parseInt(narrative.getNarrativeType().getCode()) == NARRATIVE_TYPE_ED_SF424_SUPPLIMENT) { attachedFileDataType = getAttachedFileType(narrative); if (attachedFileDataType != null) { edsf424Supplement.setAttachment(attachedFileDataType); break; } } } edsf424SupplementDocument.setEDSF424Supplement(edsf424Supplement); return edsf424SupplementDocument; }