List of usage examples for org.hibernate.internal.util StringHelper isNotEmpty
public static boolean isNotEmpty(String string)
From source file:com.devnexus.ting.core.hibernate.ImprovedPluralizedNamingStrategy.java
License:Apache License
/** * Return the column name or the unqualified property name *//*from w w w . j a va 2 s . c o m*/ public String logicalColumnName(String columnName, String propertyName) { return StringHelper.isNotEmpty(columnName) ? columnName : StringHelper.unqualify(propertyName); }
From source file:com.devnexus.ting.core.hibernate.ImprovedPluralizedNamingStrategy.java
License:Apache License
/** * Return the column name if explicit or the concatenation of the property name and the referenced column */// w w w .ja va 2 s. c o m public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) { return StringHelper.isNotEmpty(columnName) ? columnName : StringHelper.unqualify(propertyName) + "_" + referencedColumn; }
From source file:io.gumga.application.spring.config.GumgaNamingStrategy.java
@Override public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) { return oracleSafe(StringHelper.isNotEmpty(columnName) ? columnName : StringHelper.unqualify(propertyName) + "_" + referencedColumn); }
From source file:io.gumga.application.spring.config.GumgaNamingStrategy.java
@Override public String logicalColumnName(String columnName, String propertyName) { return oracleSafe(StringHelper.isNotEmpty(columnName) ? columnName : StringHelper.unqualify(propertyName)); }
From source file:nebula.cfg.DefaultNamingStrategy.java
License:Open Source License
/** * Return the column name if explicit or the concatenation of the property name and the referenced column * *//*from w w w . j a v a 2 s. co m*/ public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) { return StringHelper.isNotEmpty(columnName) ? columnName : propertyName + "_" + referencedColumn; }
From source file:org.gluu.oxtrust.util.CopyUtils.java
License:MIT License
private static void setGluuStatus(GluuCustomPerson destination, String active) { if (StringHelper.isNotEmpty(active) && (destination.getAttribute("gluuStatus") == null)) { GluuBoolean gluuStatus = GluuBoolean.getByValue(org.xdi.util.StringHelper.toLowerCase(active)); if (gluuStatus != null) { destination.setAttribute("gluuStatus", gluuStatus.getValue()); }//from w w w .jav a 2s. co m } }
From source file:org.grails.orm.hibernate.cfg.GrailsHibernateUtil.java
License:Apache License
public static boolean isNotEmpty(final String string) { return StringHelper.isNotEmpty(string); }
From source file:org.lightmare.jpa.hibernate.internal.PersistenceXmlParserImpl.java
License:Open Source License
private void bindPersistenceUnit(ParsedPersistenceXmlDescriptor persistenceUnit, Element persistenceUnitElement) { final String name = persistenceUnitElement.getAttribute("name"); if (StringHelper.isNotEmpty(name)) { LOG.tracef("Persistence unit name from persistence.xml : %s", name); persistenceUnit.setName(name);/*w ww . ja v a2s . c om*/ } final PersistenceUnitTransactionType transactionType = parseTransactionType( persistenceUnitElement.getAttribute("transaction-type")); if (transactionType != null) { persistenceUnit.setTransactionType(transactionType); } NodeList children = persistenceUnitElement.getChildNodes(); boolean resolvedClasses = Boolean.FALSE; for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) children.item(i); String tag = element.getTagName(); if (tag.equals("non-jta-data-source")) { persistenceUnit.setNonJtaDataSource(extractContent(element)); } else if (tag.equals("jta-data-source")) { persistenceUnit.setJtaDataSource(extractContent(element)); } else if (tag.equals("provider")) { persistenceUnit.setProviderClassName(extractContent(element)); } else if (tag.equals("class")) { if (CollectionUtils.invalid(MetaConfig.getClasses(metaConfig))) { persistenceUnit.addClasses(extractContent(element)); } else if (Boolean.FALSE.equals(resolvedClasses)) { PersistenceDescriptorUtils.resolveEntities(persistenceUnit, metaConfig); resolvedClasses = Boolean.TRUE; } } else if (tag.equals("mapping-file")) { persistenceUnit.addMappingFiles(extractContent(element)); } else if (tag.equals("jar-file")) { persistenceUnit.addJarFileUrl(ArchiveHelper.getURLFromPath(extractContent(element))); } else if (tag.equals("exclude-unlisted-classes")) { persistenceUnit.setExcludeUnlistedClasses(extractBooleanContent(element, true)); } else if (tag.equals("delimited-identifiers")) { persistenceUnit.setUseQuotedIdentifiers(true); } else if (tag.equals("validation-mode")) { persistenceUnit.setValidationMode(extractContent(element)); } else if (tag.equals("shared-cache-mode")) { persistenceUnit.setSharedCacheMode(extractContent(element)); } else if (tag.equals("properties")) { NodeList props = element.getChildNodes(); for (int j = 0; j < props.getLength(); j++) { if (props.item(j).getNodeType() == Node.ELEMENT_NODE) { Element propElement = (Element) props.item(j); if (!"property".equals(propElement.getTagName())) { continue; } String propName = propElement.getAttribute("name").trim(); String propValue = propElement.getAttribute("value").trim(); if (StringHelper.isEmpty(propValue)) { // fall back to the natural (Hibernate) way of // description propValue = extractContent(propElement, ""); } persistenceUnit.getProperties().put(propName, propValue); } } } } } if (Boolean.FALSE.equals(resolvedClasses)) { PersistenceDescriptorUtils.resolveEntities(persistenceUnit, metaConfig); } }
From source file:testHttp.wangdaizhijia.GetWDZJ.java
public void json2Model(String json) throws IOException, SQLException, ParserException { JSONObject jsonObject = JSONObject.fromObject(json); String rowCount = jsonObject.get("rowCount").toString(); dateCount = Integer.parseInt(rowCount); List list = (List) jsonObject.get("list"); for (int i = 0; i < list.size(); i++) { Map map = (Map) list.get(i); String splatid = (String) map.get("platId"); String querySql = "select * from cred_wdzj_platinfo where splatid = " + splatid; ResultSet count = statement2.executeQuery(querySql); if (count.next()) { System.out.println("" + excount++); continue; }//from w ww. ja va 2 s . c o m String splatname = (String) map.get("platName"); int splatStatus = (Integer) map.get("platStatus"); String platPin = (String) map.get("platPin"); String splaturl = (String) map.get("platUrl"); String slocationareaname = map.get("locationAreaName") + "," + map.get("locationCityName"); String sonlinedate = (String) map.get("onlineDate"); String splatearnings = map.get("platEarnings").toString(); Double iregisteredcapital = Double.parseDouble(map.get("registeredCapital").toString()); String swithdrawspeed; if (map.get("withdrawSpeed") != null) { swithdrawspeed = map.get("withdrawSpeed").toString(); } else swithdrawspeed = ""; String sterm = (String) map.get("term"); Double iriskreserve = (Double) map.get("riskReserve"); String url = "http://www.wdzj.com/dangan/" + platPin; TestHttp testHttp = new TestHttp(); HttpRespons hr = testHttp.send(url, "GET", null, null); String result = hr.getContent(); Parser parser = new Parser(); parser.setInputHTML(result); parser.setEncoding("utf-8");//? NodeFilter[] filters = new NodeFilter[3]; filters[0] = new AndFilter(new TagNameFilter("span"), new HasAttributeFilter("class", "name")); filters[1] = new HasChildFilter(filters[0]); filters[2] = new TagNameFilter("li"); NodeFilter contentFilter = new AndFilter(filters[2], filters[1]); Map<String, String> platInfo = new HashMap<String, String>(); NodeList nodes = parser.extractAllNodesThatMatch(contentFilter);//filter?nodes for (int k = 1; k < nodes.size(); k++) { String value = nodes.elementAt(k).toPlainTextString().trim(); String describe = nodes.elementAt(k).getChildren().elementAt(0).toPlainTextString().trim(); platInfo.put(describe, value); } String ssecuritymodelother = platInfo.get("??"); ssecuritymodelother = this.formatString(ssecuritymodelother); String screditassignment = platInfo.get("?"); String sfundcustodian = platInfo.get(""); String sbidsecurity = platInfo.get("?"); String sguaranteeinstitutions = platInfo.get("?"); sguaranteeinstitutions = this.formatString(sguaranteeinstitutions); String sbustype = platInfo.get(""); parser.setInputHTML(result); NodeFilter aboutFilter = new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "bd aboutBd")); NodeList divnodes = parser.extractAllNodesThatMatch(aboutFilter);//filter?nodes platInfo.put("?", divnodes.asString()); String splantbrief = platInfo.get("?");//? splantbrief = this.formatString(splantbrief); parser.setInputHTML(result); NodeFilter componyFilters = new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "bd inforBd")); NodeList componynodes = parser.extractAllNodesThatMatch(componyFilters);//filter?nodes NodeList child = componynodes.elementAt(0).getChildren(); NodeList spanList = child.extractAllNodesThatMatch(new TagNameFilter("span")); Map<String, String> componyMap = new HashMap<String, String>(); for (int j = 0; j < spanList.size(); j++) { String describe = spanList.elementAt(j).toPlainTextString().trim(); String value; if (j < spanList.size() - 1) { value = child.toString().substring(child.toString().indexOf(describe) + describe.length(), child.toString().indexOf(spanList.elementAt(j + 1).toPlainTextString().trim())); } else { value = child.toString().substring(child.toString().indexOf(describe) + describe.length()); } describe = describe.substring(0, describe.length() - 1); componyMap.put(describe, value.trim()); } String scompanyname = componyMap.get("???");//??? String scompanylegal = componyMap.get("?");//? String scompanytype = componyMap.get("?");//? String sshareholderstructure = componyMap.get(""); // sshareholderstructure = formatString(sshareholderstructure); String sregisteredcapital = componyMap.get("");// String sactualcapital = componyMap.get("");// String sregisteredaddr = componyMap.get("?");//? String sopendate = componyMap.get("");// String sapprovaldate = componyMap.get("");// String sregistrationauthority = componyMap.get("");// String sbusinesslicensenum = componyMap.get("??");//?? String sorgcode = componyMap.get("?");//? String staxregistrationnum = componyMap.get("?");//? parser.setInputHTML(result); NodeFilter tableFilter = new NodeClassFilter(TableTag.class); NodeFilter fatherFilter = new HasParentFilter( new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "bd webRecordBd"))); AndFilter andFilter = new AndFilter(tableFilter, fatherFilter); List<List<String>> mapList = new ArrayList<List<String>>(); NodeList tableList = parser.extractAllNodesThatMatch(andFilter); for (int table = 0; table <= tableList.size(); table++) { if (tableList.elementAt(table) instanceof TableTag) { TableTag tag = (TableTag) tableList.elementAt(table); TableRow[] rows = tag.getRows(); for (int j = 0; j < rows.length; j++) { List<String> tdlist = new ArrayList(); TableRow tr = rows[j]; TableColumn[] td = tr.getColumns(); for (int k = 0; k < td.length; k++) { tdlist.add(td[k].toPlainTextString().trim()); } if (tdlist.size() > 0) { mapList.add(tdlist); } } } } Map<String, String> tableMap = new HashMap(); if (mapList != null && mapList.size() > 1 && mapList.get(0).size() == mapList.get(1).size()) { for (int j = 0; j < mapList.get(0).size(); j++) { tableMap.put(mapList.get(0).get(j), mapList.get(1).get(j)); } } else { System.out.println(mapList); } String sfilingurl = tableMap.get("??");//?? String sfilingurldate = tableMap.get("??");//?? String sfilingtype = tableMap.get("??");//?? String sfilingcompanyname = tableMap.get("????");//???? String sfilingipcnum = tableMap.get("ICP?");//ICP? parser.setInputHTML(result); NodeFilter feeFilters = new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "bd costBd")); NodeList feenodes = parser.extractAllNodesThatMatch(feeFilters);//filter?nodes NodeList feechild = feenodes.elementAt(0).getChildren(); NodeList feeList = feechild.extractAllNodesThatMatch(new TagNameFilter("span")); Map<String, String> feeMap = new HashMap<String, String>(); for (int j = 0; j < feeList.size(); j++) { String describe = feeList.elementAt(j).toPlainTextString().trim(); String value; if (j < feeList.size() - 1) { value = feechild.toString().substring(feechild.toString().indexOf(describe) + describe.length(), feechild.toString().indexOf(feeList.elementAt(j + 1).toPlainTextString().trim())); } else { value = feechild.toString() .substring(feechild.toString().indexOf(describe) + describe.length()); } describe = describe.substring(0, describe.length() - 1); feeMap.put(describe, value.trim()); } String smanagefee = feeMap.get("?");//? smanagefee = this.formatString(smanagefee); String srechargefee = feeMap.get("");// srechargefee = this.formatString(srechargefee); String scashoutfee = feeMap.get("??");//?? scashoutfee = this.formatString(scashoutfee); String svipfee = feeMap.get("VIP");// VIP svipfee = this.formatString(svipfee); String stransferfee = feeMap.get("");// stransferfee = this.formatString(stransferfee); String spaytype = feeMap.get("?");//? NodeList otherNode = feenodes.elementAt(1).getChildren(); NodeList otherList = otherNode.extractAllNodesThatMatch(new TagNameFilter("span")); Map<String, String> otherMap = new HashMap<String, String>(); for (int j = 0; j < otherList.size(); j++) { String describe = otherList.elementAt(j).toPlainTextString().trim(); String value; if (j < otherList.size() - 1) { value = otherNode.toString().substring( otherNode.toString().indexOf(describe) + describe.length(), otherNode.toString().indexOf(otherList.elementAt(j + 1).toPlainTextString().trim())); } else { value = otherNode.toString() .substring(otherNode.toString().indexOf(describe) + describe.length()); } describe = describe.substring(0, describe.length() - 1); otherMap.put(describe, value.trim()); } String saddr = otherMap.get("??");// ?? String sservicetel = otherMap.get("400?");//400? String scompanytel = otherMap.get("??");//?? String scompanyfax = otherMap.get("?");//? String sservicemail = otherMap.get("?");//? int iid = getSeqNextVal("SEQ_CRED_WDZJ_PLATINFO"); String sp2porgcode = "Q1015290000001".substring(0, 14 - String.valueOf(iid).length()) + iid;// ps.setInt(1, iid); //iid ps.setString(2, splatid);// ps.setString(3, splatname);// ps.setString(4, splaturl);// ps.setString(5, slocationareaname);// ps.setString(6, sonlinedate);// ps.setString(7, splatearnings);// ps.setDouble(8, iregisteredcapital);// ps.setString(9, swithdrawspeed);// ps.setString(10, sterm);// ps.setDouble(11, iriskreserve);// ps.setString(12, ssecuritymodelother);// ps.setString(13, screditassignment);// ps.setString(14, sfundcustodian);// ps.setString(15, sbidsecurity);// ps.setString(16, sguaranteeinstitutions);// ps.setString(17, sbustype);// StringReader reader = new StringReader(splantbrief); ps.setCharacterStream(18, reader, splantbrief.length()); ps.setString(19, scompanyname);// ps.setString(20, scompanylegal);// ps.setString(21, scompanytype); ps.setString(22, sshareholderstructure); ps.setString(23, sregisteredcapital); ps.setString(24, sactualcapital); ps.setString(25, sregisteredaddr); ps.setString(26, sopendate); ps.setString(27, sapprovaldate); ps.setString(28, sregistrationauthority); ps.setString(29, sbusinesslicensenum); ps.setString(30, sorgcode); ps.setString(31, staxregistrationnum); ps.setString(32, sfilingurl); ps.setString(33, sfilingurldate); ps.setString(34, sfilingtype); ps.setString(35, sfilingcompanyname); ps.setString(36, sfilingipcnum); ps.setString(37, smanagefee); ps.setString(38, srechargefee); ps.setString(39, scashoutfee); ps.setString(40, svipfee); ps.setString(41, stransferfee); ps.setString(42, spaytype); ps.setString(43, saddr); ps.setString(44, sservicetel); ps.setString(45, scompanytel); ps.setString(46, scompanyfax); ps.setString(47, sservicemail); ps.setString(48, sp2porgcode); ps.setInt(49, splatStatus); ps.execute(); sucessCount++; /** * ?? */ parser.setInputHTML(result); NodeFilter sbdivFilter = new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "bd peopleBd")); NodeFilter sbpFilter = new HasParentFilter(sbdivFilter); NodeFilter tagFilter = new TagNameFilter("ul"); AndFilter sbandFilter = new AndFilter(tagFilter, sbpFilter); NodeList nodeList = parser.extractAllNodesThatMatch(sbandFilter); String html = nodeList.toString(); String[] arr = html.split("\n"); List<String> sblist = new ArrayList<String>(); for (int k = 0; k < arr.length; k++) { if (StringHelper.isNotEmpty(arr[k].trim())) { sblist.add(arr[k].trim()); } } if (sblist.size() > 0 && sblist.size() % 3 != 0) { System.out.println("" + splatid + splatname + platPin + sblist); ReadWriteFileWithEncode.write("D:\\code\\TestCode\\logs\\wdzj.txt", "" + splatid + splatname + platPin + sblist, "UTF-8"); } else { for (int j = 0; j < sblist.size(); j += 3) { StringBuffer sb = new StringBuffer( "insert into CRED_WDZJ_PLATEXECUTIVE (SPLATID, SNAME, SGRAY, SBRIEF)\n" + "values ("); sb.append("'" + splatid + "',"); if (sblist.get(j).length() > 50) { ReadWriteFileWithEncode.write("D:\\code\\TestCode\\logs\\wdzj.txt", "" + splatid + splatname + platPin + sblist, "UTF-8"); break; } sb.append("'" + sblist.get(j) + "',"); sb.append("'" + sblist.get(j + 1) + "',"); sb.append("'" + sblist.get(j + 2) + "')"); statement2.execute(sb.toString()); } } } }