List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:org.kepler.objectmanager.library.LibIndex.java
/** * Figure out what the LEFT integer should be for a new row that is to be * inserted in alphabetical order for the current getParent() value. Or for * Level 1 if getParent() == null// w ww. j a v a2 s. c o m * * @param stmt * @return * @throws SQLException */ private int getAlphabeticInsertIndex(LibItem li) throws SQLException { int insertIndex = -1; int parentLevel = 0; String query = "select LIID,RGT,LEVEL,LSID,NAME from " + LibIndex.LIBRARY_INDEX_TABLE_NAME; if (li.getParent() == null) { query += " where LEVEL = 1"; } else { query += " where PARENT = " + li.getParent(); } query += " order by NAME "; if (isDebugging) { log.debug(query); } ResultSet rs = null; int cnt = 0; try { rs = _stmt.executeQuery(query); if (rs == null) log.error("Query Failed: " + query); int prevRight = -1; while (rs.next()) { int liid = rs.getInt(1); // LIID int r = rs.getInt(2); // RGT parentLevel = rs.getInt(3) - 1; // LEVEL String lsid = rs.getString(4); // LSID String n = rs.getString(5); // NAME int comparison = n.compareToIgnoreCase(li.getName()); if (comparison == 0) { log.debug(lsid); log.debug(li.getLsid()); if (lsid.equals(li.getLsid())) { log.debug("LSID matches"); throw new SQLException( li.getName() + " already exists as child of parent " + li.getParent()); } else { log.debug("LSID does not match"); try { // Add the lsid to the Library_lsids table insertLiidLsid(liid, li.getLsid()); return -1; } catch (SQLException sqle) { throw new SQLException("bummer"); } } } if (comparison > 0) { // we want to insert before this item if (cnt == 0) { // this is the first child // use the parents' left index break; } else { // use the right index of the previous row plus 1 insertIndex = prevRight + 1; } } if (comparison < 0) { // Go on to the next child, unless there is no next child // for that case we'll set this to be the current right plus 1 // every pass through the loop insertIndex = r + 1; } prevRight = r; cnt++; } } finally { if (rs != null) { rs.close(); } } if (cnt == 0) { if (isDebugging) log.debug("No children found for parent " + li.getParent()); // Or we're inserting at the top of the list if (li.getParent() == null) { // we're inserting at the very beginning insertIndex = 0; } else { String parentQuery = "SELECT LFT,LEVEL from " + LibIndex.LIBRARY_INDEX_TABLE_NAME + " WHERE LIID = " + li.getParent(); if (isDebugging) { log.debug(parentQuery); } ResultSet parentResult = null; try { parentResult = _stmt.executeQuery(parentQuery); if (parentResult == null) log.error("Query Failed: " + parentQuery); if (parentResult.next()) { insertIndex = parentResult.getInt(1) + 1; parentLevel = parentResult.getInt(2); } } finally { if (parentResult != null) { parentResult.close(); } } } } if (isDebugging) log.debug("return: " + insertIndex); li.setLevel(parentLevel + 1); return insertIndex; }
From source file:com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.java
private void setValue(JSONObject jsonObject, Element element, String defaultType) { String clazz = getClass(element); String type = getType(element); type = (type == null) ? defaultType : type; String key = removeNamespacePrefix(element.getQualifiedName()); if (hasNamespaces(element) && !skipNamespaces) { setOrAccumulate(jsonObject, key, simplifyValue(jsonObject, processElement(element, type))); return;//from ww w .java 2 s.com } else if (element.getAttributeCount() > 0) { if (isFunction(element)) { Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params")); String text = element.getValue(); String[] params = StringUtils.split(paramsAttribute.getValue(), ","); setOrAccumulate(jsonObject, key, new JSONFunction(params, text)); return; } /* * else{ setOrAccumulate( jsonObject, key, simplifyValue( jsonObject, * processElement( element, type ) ) ); return; } */ } boolean classProcessed = false; if (clazz != null) { if (clazz.compareToIgnoreCase(JSONTypes.ARRAY) == 0) { setOrAccumulate(jsonObject, key, processArrayElement(element, type)); classProcessed = true; } else if (clazz.compareToIgnoreCase(JSONTypes.OBJECT) == 0) { setOrAccumulate(jsonObject, key, simplifyValue(jsonObject, processObjectElement(element, type))); classProcessed = true; } } if (!classProcessed) { if (type.compareToIgnoreCase(JSONTypes.BOOLEAN) == 0) { setOrAccumulate(jsonObject, key, Boolean.valueOf(element.getValue())); } else if (type.compareToIgnoreCase(JSONTypes.NUMBER) == 0) { // try integer first try { setOrAccumulate(jsonObject, key, Integer.valueOf(element.getValue())); } catch (NumberFormatException e) { setOrAccumulate(jsonObject, key, Double.valueOf(element.getValue())); } } else if (type.compareToIgnoreCase(JSONTypes.INTEGER) == 0) { setOrAccumulate(jsonObject, key, Integer.valueOf(element.getValue())); } else if (type.compareToIgnoreCase(JSONTypes.FLOAT) == 0) { setOrAccumulate(jsonObject, key, Double.valueOf(element.getValue())); } else if (type.compareToIgnoreCase(JSONTypes.FUNCTION) == 0) { String[] params = null; String text = element.getValue(); Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params")); if (paramsAttribute != null) { params = StringUtils.split(paramsAttribute.getValue(), ","); } setOrAccumulate(jsonObject, key, new JSONFunction(params, text)); } else if (type.compareToIgnoreCase(JSONTypes.STRING) == 0) { // see if by any chance has a 'params' attribute Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params")); if (paramsAttribute != null) { String[] params = null; String text = element.getValue(); params = StringUtils.split(paramsAttribute.getValue(), ","); setOrAccumulate(jsonObject, key, new JSONFunction(params, text)); } else { if (isArray(element, false)) { setOrAccumulate(jsonObject, key, processArrayElement(element, defaultType)); } else if (isObject(element, false)) { setOrAccumulate(jsonObject, key, simplifyValue(jsonObject, processObjectElement(element, defaultType))); } else { setOrAccumulate(jsonObject, key, trimSpaceFromValue(element.getValue())); } } } } }
From source file:org.iexhub.connectors.XdsBRepositoryManager.java
/** * @param cdaDocument/*from www . ja v a2s . c om*/ * @param mimeType * @return * @throws Exception */ public RegistryResponseType provideAndRegisterDocumentSet(byte[] cdaDocument, String mimeType) throws Exception { // Support only for a single document per submission set... if (mimeType.compareToIgnoreCase("text/xml") != 0) { throw new DocumentTypeUnsupportedException( "Only XML documents currently supported for ProvideAndRegisterDocumentSet"); } try { ProvideAndRegisterDocumentSetRequestType documentSetRequest = new ProvideAndRegisterDocumentSetRequestType(); // Create SubmitObjectsRequest... SubmitObjectsRequest submitObjectsRequest = new SubmitObjectsRequest(); // Create RegistryObjectList... RegistryObjectListType registryObjectList = new RegistryObjectListType(); // Create ExtrinsicObject... DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); InputStream is = new ByteArrayInputStream(cdaDocument); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); Document doc = dBuilder.parse(new InputSource(reader)); String documentId = UUID.randomUUID().toString(); ExtrinsicObjectType extrinsicObject = new ExtrinsicObjectType(); extrinsicObject.setId(documentId); extrinsicObject.setMimeType(mimeType); extrinsicObject.setObjectType("urn:uuid:7edca82f-054d-47f2-a032-9b2a5b5186c1"); // Create creationTime rim:Slot... ValueListType valueList = null; SlotType1 slot = new SlotType1(); slot.setName("creationTime"); XPath xPath = getCustomXPath(); NodeList nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:effectiveTime", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { valueList = new ValueListType(); valueList.getValue().add(((Element) nodes.item(0)).getAttribute("value")); slot.setValueList(valueList); extrinsicObject.getSlot().add(slot); } // Create languageCode rim:Slot... xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:languageCode", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { slot = new SlotType1(); slot.setName("languageCode"); valueList = new ValueListType(); valueList.getValue().add(((Element) nodes.item(0)).getAttribute("code")); slot.setValueList(valueList); extrinsicObject.getSlot().add(slot); } // Create serviceStartTime rim:Slot... xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:documentationOf/hl7:serviceEvent/hl7:effectiveTime/hl7:low", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { slot = new SlotType1(); slot.setName("serviceStartTime"); valueList = new ValueListType(); valueList.getValue().add(((Element) nodes.item(0)).getAttribute("value")); slot.setValueList(valueList); extrinsicObject.getSlot().add(slot); } // Create serviceStopTime rim:Slot... xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:documentationOf/hl7:serviceEvent/hl7:effectiveTime/high", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { slot = new SlotType1(); slot.setName("serviceStopTime"); valueList = new ValueListType(); valueList.getValue().add(((Element) nodes.item(0)).getAttribute("value")); slot.setValueList(valueList); extrinsicObject.getSlot().add(slot); } // Create sourcePatientId rim:Slot... xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:id", doc.getDocumentElement(), XPathConstants.NODESET); String patientId = null; if (nodes.getLength() > 0) { slot = new SlotType1(); slot.setName("sourcePatientId"); valueList = new ValueListType(); patientId = ((Element) nodes.item(0)).getAttribute("extension") + "^^^&" + ((Element) nodes.item(0)).getAttribute("root") + "&ISO"; valueList.getValue().add(patientId); slot.setValueList(valueList); extrinsicObject.getSlot().add(slot); } // Create sourcePatientInfo rim:Slot... xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:patient/hl7:name/hl7:family", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { slot = new SlotType1(); slot.setName("sourcePatientInfo"); valueList = new ValueListType(); valueList.getValue().add("PID-3|" + patientId); StringBuilder name = new StringBuilder(); name.append("PID-5|" + ((Element) nodes.item(0)).getTextContent() + "^"); xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:patient/hl7:name/hl7:given", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { name.append(((Element) nodes.item(0)).getTextContent() + "^^"); } else { name.append("^^"); } xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:patient/hl7:name/hl7:prefix", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { name.append(((Element) nodes.item(0)).getTextContent() + "^"); } else { name.append("^"); } xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:patient/hl7:name/hl7:suffix", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { name.append(((Element) nodes.item(0)).getTextContent()); } valueList.getValue().add(name.toString()); xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:patient/hl7:birthTime", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { valueList.getValue().add("PID-7|" + ((Element) nodes.item(0)).getAttribute("value")); } xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:patient/hl7:administrativeGenderCode", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { valueList.getValue().add("PID-8|" + ((Element) nodes.item(0)).getAttribute("code")); } xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:addr", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { StringBuilder address = new StringBuilder(); address.append("PID-11|"); xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:addr/hl7:streetAddressLine", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { address.append(((Element) nodes.item(0)).getTextContent() + "^^"); } else { address.append("^^"); } xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:addr/hl7:city", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { address.append(((Element) nodes.item(0)).getTextContent() + "^"); } else { address.append("^"); } xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:addr/hl7:state", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { address.append(((Element) nodes.item(0)).getTextContent() + "^"); } else { address.append("^"); } xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:addr/hl7:postalCode", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { address.append(((Element) nodes.item(0)).getTextContent() + "^"); } else { address.append("^"); } xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate( "/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:addr/hl7:country", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { address.append(((Element) nodes.item(0)).getTextContent()); } else { address.append("^"); } valueList.getValue().add(address.toString()); } slot.setValueList(valueList); extrinsicObject.getSlot().add(slot); } // Create classifications - start with document author(s)... ArrayList<ClassificationType> documentAuthorClassifications = new ArrayList<ClassificationType>(); xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:author", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { for (int i = 0; i < nodes.getLength(); ++i) { ClassificationType documentAuthorClassification = new ClassificationType(); documentAuthorClassification.setId(UUID.randomUUID().toString()); documentAuthorClassification.setClassificationScheme(documentAuthorClassificationScheme); documentAuthorClassification.setClassifiedObject(documentId); documentAuthorClassification.setNodeRepresentation(""); slot = new SlotType1(); slot.setName("authorPerson"); // authorPerson rim:Slot StringBuilder authorName = new StringBuilder(); xPath = getCustomXPath(); NodeList subNodes = (NodeList) xPath.evaluate("hl7:assignedAuthor/hl7:assignedPerson", nodes.item(i).getChildNodes(), XPathConstants.NODESET); if (subNodes.getLength() > 0) { xPath = getCustomXPath(); NodeList assignedPersonSubNodes = (NodeList) xPath.evaluate("hl7:name/hl7:prefix", subNodes.item(0).getChildNodes(), XPathConstants.NODESET); if (assignedPersonSubNodes.getLength() > 0) { authorName.append(((Element) assignedPersonSubNodes.item(0)).getTextContent() + " "); } xPath = getCustomXPath(); assignedPersonSubNodes = (NodeList) xPath.evaluate("hl7:name/hl7:given", subNodes.item(0).getChildNodes(), XPathConstants.NODESET); if (assignedPersonSubNodes.getLength() > 0) { authorName.append(((Element) assignedPersonSubNodes.item(0)).getTextContent() + " "); } xPath = getCustomXPath(); assignedPersonSubNodes = (NodeList) xPath.evaluate("hl7:name/hl7:family", subNodes.item(0).getChildNodes(), XPathConstants.NODESET); if (assignedPersonSubNodes.getLength() > 0) { authorName.append(((Element) assignedPersonSubNodes.item(0)).getTextContent()); } xPath = getCustomXPath(); assignedPersonSubNodes = (NodeList) xPath.evaluate("hl7:name/hl7:suffix", subNodes.item(0).getChildNodes(), XPathConstants.NODESET); if (assignedPersonSubNodes.getLength() > 0) { authorName.append(" " + ((Element) assignedPersonSubNodes.item(0)).getTextContent()); } } else { // If assignedAuthor is not present, then check for representedOrganization/name... subNodes = (NodeList) xPath.evaluate( "hl7:assignedAuthor/hl7:representedOrganization/hl7:name", nodes.item(i).getChildNodes(), XPathConstants.NODESET); xPath = XPathFactory.newInstance().newXPath(); if (subNodes.getLength() > 0) { authorName.append(((Element) subNodes.item(0)).getTextContent()); } } valueList = new ValueListType(); valueList.getValue().add(authorName.toString()); slot.setValueList(valueList); documentAuthorClassification.getSlot().add(slot); documentAuthorClassifications.add(documentAuthorClassification); extrinsicObject.getClassification().add(documentAuthorClassification); } } // ClassCodes classification... ClassificationType classification = new ClassificationType(); classification.setId(UUID.randomUUID().toString()); classification.setClassificationScheme(documentClassCodesClassificationScheme); classification.setClassifiedObject(documentId); xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:code", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { // from properties file classification.setNodeRepresentation(documentClassCodesNodeRepresentation); slot = new SlotType1(); slot.setName("codingScheme"); if (((Element) nodes.item(0)).getAttribute("codeSystem") != null) { valueList = new ValueListType(); // dynamically from the document or from properties file valueList.getValue().add(documentClassCodesCodingScheme); slot.setValueList(valueList); classification.getSlot().add(slot); } if (((Element) nodes.item(0)).getAttribute("displayName") != null) { InternationalStringType text = new InternationalStringType(); LocalizedStringType localizedText = new LocalizedStringType(); // dynamically from the document or from properties file localizedText.setValue(documentClassCodesName); text.getLocalizedString().add(localizedText); classification.setName(text); } extrinsicObject.getClassification().add(classification); } // ConfidentialityCodes classification... classification = new ClassificationType(); classification.setId(UUID.randomUUID().toString()); classification.setClassificationScheme(documentConfidentialityCodesClassificationScheme); classification.setClassifiedObject(documentId); xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:confidentialityCode", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { if (((Element) nodes.item(0)).getAttribute("code") != null) { classification.setNodeRepresentation(((Element) nodes.item(0)).getAttribute("code")); } slot = new SlotType1(); slot.setName("codingScheme"); if (((Element) nodes.item(0)).getAttribute("codeSystem") != null) { valueList = new ValueListType(); valueList.getValue().add(((Element) nodes.item(0)).getAttribute("codeSystem")); slot.setValueList(valueList); classification.getSlot().add(slot); } if (((Element) nodes.item(0)).getAttribute("displayName") != null) { InternationalStringType text = new InternationalStringType(); LocalizedStringType localizedText = new LocalizedStringType(); localizedText.setValue(((Element) nodes.item(0)).getAttribute("displayName")); text.getLocalizedString().add(localizedText); classification.setName(text); } extrinsicObject.getClassification().add(classification); } // FormatCodes classification... classification = new ClassificationType(); classification.setId(UUID.randomUUID().toString()); classification.setClassificationScheme(documentFormatCodesClassificationScheme); classification.setClassifiedObject(documentId); classification.setNodeRepresentation(documentFormatCodesNodeRepresentation); slot = new SlotType1(); slot.setName("codingScheme"); valueList = new ValueListType(); valueList.getValue().add(documentFormatCodesCodingScheme); slot.setValueList(valueList); classification.getSlot().add(slot); InternationalStringType text = new InternationalStringType(); LocalizedStringType localizedText = new LocalizedStringType(); localizedText.setValue(documentFormatCodesName); text.getLocalizedString().add(localizedText); classification.setName(text); extrinsicObject.getClassification().add(classification); // HealthcareFacilityTypeCodes classification... classification = new ClassificationType(); classification.setId(UUID.randomUUID().toString()); classification.setClassificationScheme(documentHealthcareFacilityTypeCodesClassificationScheme); classification.setClassifiedObject(documentId); classification.setNodeRepresentation(documentHealthcareFacilityTypeCodesNodeRepresentation); slot = new SlotType1(); slot.setName("codingScheme"); valueList = new ValueListType(); valueList.getValue().add(documentHealthcareFacilityTypeCodesCodingScheme); slot.setValueList(valueList); classification.getSlot().add(slot); text = new InternationalStringType(); localizedText = new LocalizedStringType(); localizedText.setValue(documentHealthcareFacilityTypeCodesName); text.getLocalizedString().add(localizedText); classification.setName(text); extrinsicObject.getClassification().add(classification); // PracticeSettingCodes classification... classification = new ClassificationType(); classification.setId(UUID.randomUUID().toString()); classification.setClassificationScheme(documentPracticeSettingCodesClassificationScheme); classification.setClassifiedObject(documentId); xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:code", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { if (((Element) nodes.item(0)).getAttribute("code") != null) { classification.setNodeRepresentation(documentPracticeSettingCodesNodeRepresentation); } slot = new SlotType1(); slot.setName("codingScheme"); if (((Element) nodes.item(0)).getAttribute("codeSystem") != null) { valueList = new ValueListType(); valueList.getValue().add(documentPracticeSettingCodesCodingScheme); slot.setValueList(valueList); classification.getSlot().add(slot); } if (((Element) nodes.item(0)).getAttribute("displayName") != null) { text = new InternationalStringType(); localizedText = new LocalizedStringType(); localizedText.setValue(documentPracticeSettingCodesDisplayName); text.getLocalizedString().add(localizedText); classification.setName(text); } extrinsicObject.getClassification().add(classification); } // Type code classification... classification = new ClassificationType(); classification.setId(UUID.randomUUID().toString()); classification.setClassificationScheme(documentContentTypeClassificationScheme); classification.setClassifiedObject(documentId); xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:code", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { if (((Element) nodes.item(0)).getAttribute("code") != null) { classification.setNodeRepresentation(((Element) nodes.item(0)).getAttribute("code")); } slot = new SlotType1(); slot.setName("codingScheme"); if (((Element) nodes.item(0)).getAttribute("codeSystem") != null) { valueList = new ValueListType(); valueList.getValue().add(((Element) nodes.item(0)).getAttribute("codeSystem")); slot.setValueList(valueList); classification.getSlot().add(slot); } if (((Element) nodes.item(0)).getAttribute("displayName") != null) { text = new InternationalStringType(); localizedText = new LocalizedStringType(); localizedText.setValue(((Element) nodes.item(0)).getAttribute("displayName")); text.getLocalizedString().add(localizedText); classification.setName(text); } extrinsicObject.getClassification().add(classification); } // Create rim:ExternalIdentifier(s) - first the XDSDocumentEntry.patientId value(s)... xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:recordTarget/hl7:patientRole/hl7:id", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { ExternalIdentifierType externalIdentifierPatientId = new ExternalIdentifierType(); externalIdentifierPatientId.setId(UUID.randomUUID().toString()); externalIdentifierPatientId.setRegistryObject(documentId); externalIdentifierPatientId .setIdentificationScheme(extrinsicObjectExternalIdentifierPatientIdIdentificationScheme); externalIdentifierPatientId.setValue(((Element) nodes.item(0)).getAttribute("extension") + "^^^&" + ((Element) nodes.item(0)).getAttribute("root") + "&ISO"); text = new InternationalStringType(); localizedText = new LocalizedStringType(); localizedText.setValue(extrinsicObjectExternalIdentifierPatientIdName); text.getLocalizedString().add(localizedText); externalIdentifierPatientId.setName(text); extrinsicObject.getExternalIdentifier().add(externalIdentifierPatientId); } // Now the XDSDocumentEntry.uniqueId value(s)... xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:id", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { ExternalIdentifierType externalIdentifierDocumentId = new ExternalIdentifierType(); externalIdentifierDocumentId.setId(UUID.randomUUID().toString()); externalIdentifierDocumentId.setRegistryObject(documentId); externalIdentifierDocumentId .setIdentificationScheme(extrinsicObjectExternalIdentifierUniqueIdIdentificationScheme); if (testMode) { DateTime testDocId = DateTime.now(DateTimeZone.UTC); externalIdentifierDocumentId .setValue(((Element) nodes.item(0)).getAttribute("root") + "^" + testDocId.getMillis()); } else { externalIdentifierDocumentId.setValue(((Element) nodes.item(0)).getAttribute("root") + "^" + ((Element) nodes.item(0)).getAttribute("extension")); } text = new InternationalStringType(); localizedText = new LocalizedStringType(); localizedText.setValue(extrinsicObjectExternalIdentifierUniqueIdName); text.getLocalizedString().add(localizedText); externalIdentifierDocumentId.setName(text); extrinsicObject.getExternalIdentifier().add(externalIdentifierDocumentId); } registryObjectList.getIdentifiable().add(objectFactory.createExtrinsicObject(extrinsicObject)); // Create rim:RegistryPackage... String submissionSetId = UUID.randomUUID().toString(); RegistryPackageType registryPackage = new RegistryPackageType(); registryPackage.setId(submissionSetId); // Create rim:RegistryPackage/submissionTime attribute... slot = new SlotType1(); slot.setName("submissionTime"); valueList = new ValueListType(); DateTime now = new DateTime(DateTimeZone.UTC); StringBuilder timeBuilder = new StringBuilder(); timeBuilder.append(now.getYear()); timeBuilder.append((now.getMonthOfYear() < 10) ? ("0" + now.getMonthOfYear()) : now.getMonthOfYear()); timeBuilder.append((now.getDayOfMonth() < 10) ? ("0" + now.getDayOfMonth()) : now.getDayOfMonth()); timeBuilder.append((now.getHourOfDay() < 10) ? ("0" + now.getHourOfDay()) : now.getHourOfDay()); timeBuilder .append((now.getMinuteOfHour() < 10) ? ("0" + now.getMinuteOfHour()) : now.getMinuteOfHour()); valueList.getValue().add(timeBuilder.toString()); slot.setValueList(valueList); registryPackage.getSlot().add(slot); // Recreate authorName classification(s) in rim:RegistryPackage... for (ClassificationType registryClassification : documentAuthorClassifications) { ClassificationType newClassification = new ClassificationType(); newClassification.setId(UUID.randomUUID().toString()); newClassification.setClassificationScheme(registryPackageAuthorClassificationScheme); newClassification.setClassifiedObject(submissionSetId); newClassification.setNodeRepresentation(""); if (!registryClassification.getSlot().isEmpty()) { slot = new SlotType1(); slot.setName(registryClassification.getSlot().get(0).getName()); slot.setValueList(registryClassification.getSlot().get(0).getValueList()); newClassification.getSlot().add(slot); } registryPackage.getClassification().add(newClassification); } // ContentTypeCodes classification... classification = new ClassificationType(); classification.setId(UUID.randomUUID().toString()); classification.setClassificationScheme(registryPackageContentTypeCodesClassificationScheme); classification.setClassifiedObject(submissionSetId); xPath = getCustomXPath(); nodes = (NodeList) xPath.evaluate("/hl7:ClinicalDocument/hl7:code", doc.getDocumentElement(), XPathConstants.NODESET); if (nodes.getLength() > 0) { if (((Element) nodes.item(0)).getAttribute("code") != null) { classification.setNodeRepresentation(((Element) nodes.item(0)).getAttribute("code")); } slot = new SlotType1(); slot.setName("codingScheme"); if (((Element) nodes.item(0)).getAttribute("codeSystem") != null) { valueList = new ValueListType(); valueList.getValue().add(((Element) nodes.item(0)).getAttribute("codeSystem")); slot.setValueList(valueList); classification.getSlot().add(slot); } if (((Element) nodes.item(0)).getAttribute("displayName") != null) { text = new InternationalStringType(); localizedText = new LocalizedStringType(); localizedText.setValue(((Element) nodes.item(0)).getAttribute("displayName")); text.getLocalizedString().add(localizedText); classification.setName(text); } registryPackage.getClassification().add(classification); } // ExternalIdentifiers - first XDSSubmissionSet.uniqueId... ExternalIdentifierType submissionSetUniqueId = new ExternalIdentifierType(); submissionSetUniqueId.setId(UUID.randomUUID().toString()); submissionSetUniqueId.setRegistryObject(submissionSetId); submissionSetUniqueId.setIdentificationScheme(registryPackageSubmissionSetUniqueIdIdentificationScheme); DateTime oidTimeValue = DateTime.now(DateTimeZone.UTC); submissionSetUniqueId.setValue(submissionSetOid + "." + oidTimeValue.getMillis()); text = new InternationalStringType(); localizedText = new LocalizedStringType(); localizedText.setValue(externalIdentifierSubmissionSetUniqueIdName); text.getLocalizedString().add(localizedText); submissionSetUniqueId.setName(text); registryPackage.getExternalIdentifier().add(submissionSetUniqueId); // Now XDSSubmissionSet.sourceId... ExternalIdentifierType submissionSetSourceId = new ExternalIdentifierType(); submissionSetSourceId.setId(UUID.randomUUID().toString()); submissionSetSourceId.setRegistryObject(submissionSetId); submissionSetSourceId.setIdentificationScheme(registryPackageSubmissionSetSourceIdIdentificationScheme); submissionSetSourceId.setValue(iExHubDomainOid); text = new InternationalStringType(); localizedText = new LocalizedStringType(); localizedText.setValue(externalIdentifierSubmissionSetSourceIdName); text.getLocalizedString().add(localizedText); submissionSetSourceId.setName(text); registryPackage.getExternalIdentifier().add(submissionSetSourceId); // Now XDSSubmissionSet.patientId... ExternalIdentifierType submissionSetPatientId = new ExternalIdentifierType(); submissionSetPatientId.setId(UUID.randomUUID().toString()); submissionSetPatientId.setRegistryObject(submissionSetId); submissionSetPatientId .setIdentificationScheme(registryPackageSubmissionSetPatientIdIdentificationScheme); submissionSetPatientId.setValue(patientId); text = new InternationalStringType(); localizedText = new LocalizedStringType(); localizedText.setValue(externalIdentifierSubmissionSetPatientIdName); text.getLocalizedString().add(localizedText); submissionSetPatientId.setName(text); registryPackage.getExternalIdentifier().add(submissionSetPatientId); registryObjectList.getIdentifiable().add(objectFactory.createRegistryPackage(registryPackage)); // Create SubmissionSet classification for RegistryObjectList... ClassificationType submissionSetClassification = new ClassificationType(); submissionSetClassification.setId(UUID.randomUUID().toString()); submissionSetClassification.setClassifiedObject(submissionSetId); submissionSetClassification.setClassificationNode(registryObjectListSubmissionSetClassificationNode); registryObjectList.getIdentifiable() .add(objectFactory.createClassification(submissionSetClassification)); // Create SubmissionSet Association for RegistryObjectList... AssociationType1 submissionSetAssociation = new AssociationType1(); submissionSetAssociation.setId("as01"); submissionSetAssociation .setAssociationType("urn:oasis:names:tc:ebxml-regrep:AssociationType:HasMember"); submissionSetAssociation.setSourceObject(submissionSetId); submissionSetAssociation.setTargetObject(documentId); slot = new SlotType1(); slot.setName("SubmissionSetStatus"); valueList = new ValueListType(); valueList.getValue().add("Original"); slot.setValueList(valueList); submissionSetAssociation.getSlot().add(slot); registryObjectList.getIdentifiable().add(objectFactory.createAssociation(submissionSetAssociation)); submitObjectsRequest.setRegistryObjectList(registryObjectList); documentSetRequest.setSubmitObjectsRequest(submitObjectsRequest); // Add document to message... XdsBDocumentRepository.ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType.Document documentForMessage = new XdsBDocumentRepository.ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType.Document(); documentForMessage.setValue(cdaDocument); documentForMessage.setId(documentId); documentSetRequest.getDocument().add(documentForMessage); logIti41AuditMsg(submissionSetId, patientId); if (logXdsBRequestMessages) { OMElement requestElement = repositoryStub.toOM(documentSetRequest, repositoryStub.optimizeContent(new javax.xml.namespace.QName("urn:ihe:iti:xds-b:2007", "ProvideAndRegisterDocumentSetRequest")), new javax.xml.namespace.QName("urn:ihe:iti:xds-b:2007", "ProvideAndRegisterDocumentSetRequest")); Files.write( Paths.get(logOutputPath + "/" + documentId + "_ProvideAndRegisterDocumentSetRequest.xml"), requestElement.toString().getBytes()); } return repositoryStub.documentRepository_ProvideAndRegisterDocumentSetB(documentSetRequest); } catch (Exception e) { throw e; } }
From source file:de.zib.scalaris.examples.wikipedia.bliki.WikiServlet.java
/** * Shows a page containing a list of article names. * //from ww w . j a va 2 s . com * @param request * the request of the current operation * @param response * the response of the current operation * @param result * result from reading the page list * @param connection * connection to the database * @param page * the bean for the page * * @throws IOException * @throws ServletException */ private void handleViewSpecialPageList(HttpServletRequest request, HttpServletResponse response, ValueResult<List<NormalisedTitle>> result, Connection connection, WikiPageListBean page) throws ServletException, IOException { if (result.success) { final TreeSet<String> pageList = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); MyWikiModel.denormalisePageTitles(result.value, namespace, pageList); page.setNotice(getParam_notice(request)); String nsPrefix = namespace.getNamespaceByNumber(page.getNamespaceId()); if (!nsPrefix.isEmpty()) { nsPrefix += ":"; } final String prefix = nsPrefix + page.getPrefix(); final String from = page.getFromPage(); final String fullFrom = nsPrefix + page.getFromPage(); final String to = page.getToPage(); final String fullTo = nsPrefix + page.getToPage(); final String search = page.getSearch().toLowerCase(); final String searchTitle = MyWikiModel.normaliseName(page.getSearch()); boolean foundMatch = false; if (!prefix.isEmpty() || !from.isEmpty() || !to.isEmpty() || !search.isEmpty()) { // only show pages with this prefix: for (Iterator<String> it = pageList.iterator(); it.hasNext();) { final String cur = it.next(); // case-insensitive "startsWith" check: if (!cur.regionMatches(true, 0, prefix, 0, prefix.length())) { it.remove(); } else if (!from.isEmpty() && cur.compareToIgnoreCase(fullFrom) <= 0) { it.remove(); } else if (!to.isEmpty() && cur.compareToIgnoreCase(fullTo) > 0) { it.remove(); } else if (!search.isEmpty() && !cur.toLowerCase().contains(search)) { it.remove(); } else if (!search.isEmpty() && cur.equals(searchTitle)) { foundMatch = true; } } } page.setPages(pageList); page.setFoundFullMatch(foundMatch); page.setWikiTitle(siteinfo.getSitename()); page.setWikiNamespace(namespace); forwardToPageJsp(request, response, connection, page, "pageSpecial_pagelist.jsp"); } else { if (result.connect_failed) { setParam_error(request, "ERROR: DB connection failed"); } else { setParam_error(request, "ERROR: page list unavailable"); addToParam_notice(request, "error: unknown error getting page list for " + page.getTitle() + ": <pre>" + result.message + "</pre>"); } showEmptyPage(request, response, connection, page); return; } page.setError(getParam_error(request)); page.setTitle(page.getTitle()); }
From source file:org.apache.hive.hplsql.Exec.java
/** * Initialize options/*from www . j ava 2 s . c o m*/ */ void initOptions() { Iterator<Map.Entry<String, String>> i = exec.conf.iterator(); while (i.hasNext()) { Entry<String, String> item = (Entry<String, String>) i.next(); String key = (String) item.getKey(); String value = (String) item.getValue(); if (key == null || value == null || !key.startsWith("hplsql.")) { continue; } else if (key.compareToIgnoreCase(Conf.CONN_DEFAULT) == 0) { exec.conf.defaultConnection = value; } else if (key.startsWith("hplsql.conn.init.")) { exec.conn.addConnectionInit(key.substring(17), value); } else if (key.startsWith(Conf.CONN_CONVERT)) { exec.conf.setConnectionConvert(key.substring(20), value); } else if (key.startsWith("hplsql.conn.")) { exec.conn.addConnection(key.substring(12), value); } else if (key.startsWith("hplsql.")) { exec.conf.setOption(key, value); } } }
From source file:net.sf.json.xml.XMLSerializer.java
private void setValue(JSONObject jsonObject, Element element, String defaultType) { String clazz = getClass(element); String type = getType(element); type = (type == null) ? defaultType : type; String key = removeNamespacePrefix(element.getQualifiedName()); if (hasNamespaces(element) && !skipNamespaces) { setOrAccumulate(jsonObject, key, simplifyValue(jsonObject, processElement(element, type))); return;/*from w w w . j av a 2 s. c o m*/ } else if (element.getAttributeCount() > 0) { if (isFunction(element)) { Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params")); String text = element.getValue(); String[] params = StringUtils.split(paramsAttribute.getValue(), ","); setOrAccumulate(jsonObject, key, new JSONFunction(params, text)); return; } /*else{ setOrAccumulate( jsonObject, key, simplifyValue( jsonObject, processElement( element, type ) ) ); return; }*/ } boolean classProcessed = false; if (clazz != null) { if (clazz.compareToIgnoreCase(JSONTypes.ARRAY) == 0) { setOrAccumulate(jsonObject, key, processArrayElement(element, type)); classProcessed = true; } else if (clazz.compareToIgnoreCase(JSONTypes.OBJECT) == 0) { setOrAccumulate(jsonObject, key, simplifyValue(jsonObject, processObjectElement(element, type))); classProcessed = true; } } if (!classProcessed) { if (type.compareToIgnoreCase(JSONTypes.BOOLEAN) == 0) { setOrAccumulate(jsonObject, key, Boolean.valueOf(element.getValue())); } else if (type.compareToIgnoreCase(JSONTypes.NUMBER) == 0) { // try integer first try { setOrAccumulate(jsonObject, key, Integer.valueOf(element.getValue())); } catch (NumberFormatException e) { setOrAccumulate(jsonObject, key, Double.valueOf(element.getValue())); } } else if (type.compareToIgnoreCase(JSONTypes.INTEGER) == 0) { setOrAccumulate(jsonObject, key, Integer.valueOf(element.getValue())); } else if (type.compareToIgnoreCase(JSONTypes.FLOAT) == 0) { setOrAccumulate(jsonObject, key, Double.valueOf(element.getValue())); } else if (type.compareToIgnoreCase(JSONTypes.FUNCTION) == 0) { String[] params = null; String text = element.getValue(); Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params")); if (paramsAttribute != null) { params = StringUtils.split(paramsAttribute.getValue(), ","); } setOrAccumulate(jsonObject, key, new JSONFunction(params, text)); } else if (type.compareToIgnoreCase(JSONTypes.STRING) == 0) { // see if by any chance has a 'params' attribute Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params")); if (paramsAttribute != null) { String[] params = null; String text = element.getValue(); params = StringUtils.split(paramsAttribute.getValue(), ","); setOrAccumulate(jsonObject, key, new JSONFunction(params, text)); } else { if (isArray(element, false)) { setOrAccumulate(jsonObject, key, processArrayElement(element, defaultType)); } else if (isObject(element, false)) { setOrAccumulate(jsonObject, key, simplifyValue(jsonObject, processObjectElement(element, defaultType))); } else { String value; if (isKeepCData && isCData(element)) { value = "<![CDATA[" + element.getValue() + "]]>"; } else { value = element.getValue(); } setOrAccumulate(jsonObject, key, trimSpaceFromValue(value)); } } } } }
From source file:com.mimp.hibernate.HiberNna.java
public ArrayList<Nna> ListaNnaSeguimiento(String clasificacion) { Session session = sessionFactory.getCurrentSession(); final String clasif = clasificacion; final ArrayList<Nna> allNna = new ArrayList(); final ArrayList<Nna> allNnaAux = new ArrayList(); final ArrayList<Nna> allNnaFinal = new ArrayList(); Work work = new Work() { @Override// w ww. j a v a2s .co m public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; Nna tempnna; Designacion desig; EstudioCaso est; String hql = "{call HN_GET_NNA_SEG(?)}"; CallableStatement statement = connection.prepareCall(hql); statement.registerOutParameter(1, OracleTypes.CURSOR); statement.execute(); temp = (ResultSet) statement.getObject(1); while (temp.next()) { tempnna = new Nna(); tempnna.setIdnna(temp.getLong(1)); tempnna.setNombre(temp.getString(2)); tempnna.setApellidoP(temp.getString(3)); tempnna.setApellidoM(temp.getString(4)); tempnna.setSexo(temp.getString(5)); tempnna.setFechaNacimiento(temp.getDate(6)); tempnna.setEdadAnhos(temp.getShort(7)); tempnna.setEdadMeses(temp.getShort(8)); tempnna.setActaNacimiento(temp.getShort(9)); tempnna.setCondicionSalud(temp.getString(10)); tempnna.setDepartamentoNacimiento(temp.getString(11)); tempnna.setProvinciaNacimiento(temp.getString(12)); tempnna.setDistritoNacimiento(temp.getString(13)); tempnna.setPaisNacimiento(temp.getString(14)); tempnna.setLugarNac(temp.getString(15)); tempnna.setFechaResolAbandono(temp.getDate(16)); tempnna.setFechaResolConsentida(temp.getDate(17)); tempnna.setClasificacion(temp.getString(18)); tempnna.setIncesto(temp.getShort(19)); tempnna.setMental(temp.getShort(20)); tempnna.setEpilepsia(temp.getShort(21)); tempnna.setAbuso(temp.getShort(22)); tempnna.setSifilis(temp.getShort(23)); tempnna.setSeguiMedico(temp.getShort(24)); tempnna.setOperacion(temp.getShort(25)); tempnna.setHiperactivo(temp.getShort(26)); tempnna.setEspecial(temp.getShort(27)); tempnna.setEnfermo(temp.getShort(28)); tempnna.setMayor(temp.getShort(29)); tempnna.setAdolescente(temp.getShort(30)); tempnna.setHermano(temp.getShort(31)); tempnna.setNn(temp.getShort(32)); tempnna.setObservaciones(temp.getString(33)); tempnna.setNResolAband(temp.getString(34)); tempnna.setNResolCons(temp.getString(35)); try { expnna = getExpNna(temp.getLong(1)); if (expnna.getIdexpedienteNna() != 0) { Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>(); listexp.add(expnna); tempnna.setExpedienteNnas(listexp); } } catch (Exception e) { } allNnaAux.add(tempnna); } statement.close(); temp.close(); //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO for (Nna auxnna : allNnaAux) { Set<Designacion> listDesig = new HashSet<Designacion>(); String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, auxnna.getIdnna()); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); while (rs2.next()) { desig = new Designacion(); desig.setIddesignacion(rs2.getLong(1)); desig.setNDesignacion(rs2.getString(5)); desig.setPrioridad(rs2.getLong(6)); desig.setFechaPropuesta(rs2.getDate(7)); desig.setFechaConsejo(rs2.getDate(8)); desig.setAceptacionConsejo(rs2.getShort(9)); desig.setTipoPropuesta(rs2.getString(10)); desig.setObs(rs2.getString(11)); listDesig.add(desig); } auxnna.setDesignacions(listDesig); allNna.add(auxnna); statement2.close(); rs2.close(); } for (Nna auxnna : allNna) { if (auxnna.getClasificacion().equals("prioritario")) { Set<EstudioCaso> listEst = new HashSet<EstudioCaso>(); String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, auxnna.getIdnna()); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet rs3 = (ResultSet) statement3.getObject(2); while (rs3.next()) { est = new EstudioCaso(); est.setIdestudioCaso(rs3.getLong(1)); est.setOrden(rs3.getString(4)); est.setFechaEstudio(rs3.getDate(5)); est.setFechaSolAdop(rs3.getDate(6)); est.setResultado(rs3.getString(7)); est.setPrioridad(rs3.getLong(8)); est.setNSolicitud(rs3.getLong(9)); listEst.add(est); } auxnna.setEstudioCasos(listEst); statement3.close(); rs3.close(); } allNnaFinal.add(auxnna); } //METODO BUBBLESORT PARA ORDENAR POR CODIGO if (clasif.equals("prioritario")) { Nna auxnna2; int n = allNnaFinal.size(); for (int i = 0; i < n - 1; i++) { for (int j = i; j < n - 1; j++) { if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) { if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } else { String apellidoPrev = ""; String apellidoNext = ""; try { apellidoPrev = allNnaFinal.get(i).getApellidoP(); if (apellidoPrev == null) { apellidoPrev = ""; } } catch (Exception ex) { apellidoPrev = ""; } try { apellidoNext = allNnaFinal.get(j + 1).getApellidoP(); if (apellidoNext == null) { apellidoNext = ""; } } catch (Exception ex) { apellidoNext = ""; } if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } else { Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas(); Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas(); if (!listExp2.isEmpty()) { for (ExpedienteNna exp1 : listExp1) { for (ExpedienteNna exp2 : listExp2) { String codant = exp1.getCodigoReferencia(); String codpost = exp2.getCodigoReferencia(); if (codant == null) { codant = ""; } if (codpost == null) { codpost = ""; } if (codant.compareToIgnoreCase(codpost) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } } } } } } } }; session.doWork(work); return allNnaFinal; }
From source file:com.mimp.hibernate.HiberNna.java
public ArrayList<Nna> ListaNna(String clasificacion) { Session session = sessionFactory.getCurrentSession(); final String clasif = clasificacion; final ArrayList<Nna> allNna = new ArrayList(); final ArrayList<Nna> allNnaAux = new ArrayList(); final ArrayList<Nna> allNnaFinal = new ArrayList(); Work work = new Work() { @Override//from w ww. j av a2 s. c om public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; Nna tempnna; Designacion desig; EstudioCaso est; String hql = "{call HN_GET_NNA_CLAS(?,?)}"; CallableStatement statement = connection.prepareCall(hql); statement.setString(1, clasif); statement.registerOutParameter(2, OracleTypes.CURSOR); statement.execute(); temp = (ResultSet) statement.getObject(2); while (temp.next()) { tempnna = new Nna(); tempnna.setIdnna(temp.getLong(1)); tempnna.setNombre(temp.getString(2)); tempnna.setApellidoP(temp.getString(3)); tempnna.setApellidoM(temp.getString(4)); tempnna.setSexo(temp.getString(5)); tempnna.setFechaNacimiento(temp.getDate(6)); tempnna.setEdadAnhos(temp.getShort(7)); tempnna.setEdadMeses(temp.getShort(8)); tempnna.setActaNacimiento(temp.getShort(9)); tempnna.setCondicionSalud(temp.getString(10)); tempnna.setDepartamentoNacimiento(temp.getString(11)); tempnna.setProvinciaNacimiento(temp.getString(12)); tempnna.setDistritoNacimiento(temp.getString(13)); tempnna.setPaisNacimiento(temp.getString(14)); tempnna.setLugarNac(temp.getString(15)); tempnna.setFechaResolAbandono(temp.getDate(16)); tempnna.setFechaResolConsentida(temp.getDate(17)); tempnna.setClasificacion(temp.getString(18)); tempnna.setIncesto(temp.getShort(19)); tempnna.setMental(temp.getShort(20)); tempnna.setEpilepsia(temp.getShort(21)); tempnna.setAbuso(temp.getShort(22)); tempnna.setSifilis(temp.getShort(23)); tempnna.setSeguiMedico(temp.getShort(24)); tempnna.setOperacion(temp.getShort(25)); tempnna.setHiperactivo(temp.getShort(26)); tempnna.setEspecial(temp.getShort(27)); tempnna.setEnfermo(temp.getShort(28)); tempnna.setMayor(temp.getShort(29)); tempnna.setAdolescente(temp.getShort(30)); tempnna.setHermano(temp.getShort(31)); tempnna.setNn(temp.getShort(32)); tempnna.setObservaciones(temp.getString(33)); tempnna.setNResolAband(temp.getString(34)); tempnna.setNResolCons(temp.getString(35)); try { expnna = getExpNna(temp.getLong(1)); if (expnna.getIdexpedienteNna() != 0) { Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>(); listexp.add(expnna); tempnna.setExpedienteNnas(listexp); } } catch (Exception e) { } allNnaAux.add(tempnna); } statement.close(); temp.close(); //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO for (Nna auxnna : allNnaAux) { Set<Designacion> listDesig = new HashSet<Designacion>(); String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, auxnna.getIdnna()); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); while (rs2.next()) { desig = new Designacion(); desig.setIddesignacion(rs2.getLong(1)); desig.setNDesignacion(rs2.getString(5)); desig.setPrioridad(rs2.getLong(6)); desig.setFechaPropuesta(rs2.getDate(7)); desig.setFechaConsejo(rs2.getDate(8)); desig.setAceptacionConsejo(rs2.getShort(9)); desig.setTipoPropuesta(rs2.getString(10)); desig.setObs(rs2.getString(11)); listDesig.add(desig); } auxnna.setDesignacions(listDesig); allNna.add(auxnna); statement2.close(); rs2.close(); } for (Nna auxnna : allNna) { if (auxnna.getClasificacion().equals("prioritario")) { Set<EstudioCaso> listEst = new HashSet<EstudioCaso>(); String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, auxnna.getIdnna()); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet rs3 = (ResultSet) statement3.getObject(2); while (rs3.next()) { est = new EstudioCaso(); est.setIdestudioCaso(rs3.getLong(1)); est.setOrden(rs3.getString(4)); est.setFechaEstudio(rs3.getDate(5)); est.setFechaSolAdop(rs3.getDate(6)); est.setResultado(rs3.getString(7)); est.setPrioridad(rs3.getLong(8)); est.setNSolicitud(rs3.getLong(9)); listEst.add(est); } auxnna.setEstudioCasos(listEst); statement3.close(); rs3.close(); } allNnaFinal.add(auxnna); } //METODO BUBBLESORT PARA ORDENAR POR CODIGO if (clasif.equals("prioritario")) { Nna auxnna2; int n = allNnaFinal.size(); for (int i = 0; i < n - 1; i++) { for (int j = i; j < n - 1; j++) { if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) { if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } else { String apellidoPrev = ""; String apellidoNext = ""; try { apellidoPrev = allNnaFinal.get(i).getApellidoP(); if (apellidoPrev == null) { apellidoPrev = ""; } } catch (Exception ex) { apellidoPrev = ""; } try { apellidoNext = allNnaFinal.get(j + 1).getApellidoP(); if (apellidoNext == null) { apellidoNext = ""; } } catch (Exception ex) { apellidoNext = ""; } if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } else { Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas(); Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas(); if (!listExp2.isEmpty()) { for (ExpedienteNna exp1 : listExp1) { for (ExpedienteNna exp2 : listExp2) { String codant = exp1.getCodigoReferencia(); String codpost = exp2.getCodigoReferencia(); if (codant == null) { codant = ""; } if (codpost == null) { codpost = ""; } if (codant.compareToIgnoreCase(codpost) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } } } } } } } }; session.doWork(work); return allNnaFinal; }
From source file:com.mimp.hibernate.HiberNna.java
public ArrayList<Nna> ListaNnaPrioritarios(String clasificacion) { Session session = sessionFactory.getCurrentSession(); final String clasif = clasificacion; final ArrayList<Nna> allNna = new ArrayList(); final ArrayList<Nna> allNnaAux = new ArrayList(); final ArrayList<Nna> allNnaFinal = new ArrayList(); Work work = new Work() { @Override//w ww .ja v a 2s . c om public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; Nna tempnna; Designacion desig; EstudioCaso est; String hql = "{call HN_GET_NNA_PRIO(?)}"; CallableStatement statement = connection.prepareCall(hql); statement.registerOutParameter(1, OracleTypes.CURSOR); statement.execute(); temp = (ResultSet) statement.getObject(1); while (temp.next()) { tempnna = new Nna(); tempnna.setIdnna(temp.getLong(1)); tempnna.setNombre(temp.getString(2)); tempnna.setApellidoP(temp.getString(3)); tempnna.setApellidoM(temp.getString(4)); tempnna.setSexo(temp.getString(5)); tempnna.setFechaNacimiento(temp.getDate(6)); tempnna.setEdadAnhos(temp.getShort(7)); tempnna.setEdadMeses(temp.getShort(8)); tempnna.setActaNacimiento(temp.getShort(9)); tempnna.setCondicionSalud(temp.getString(10)); tempnna.setDepartamentoNacimiento(temp.getString(11)); tempnna.setProvinciaNacimiento(temp.getString(12)); tempnna.setDistritoNacimiento(temp.getString(13)); tempnna.setPaisNacimiento(temp.getString(14)); tempnna.setLugarNac(temp.getString(15)); tempnna.setFechaResolAbandono(temp.getDate(16)); tempnna.setFechaResolConsentida(temp.getDate(17)); tempnna.setClasificacion(temp.getString(18)); tempnna.setIncesto(temp.getShort(19)); tempnna.setMental(temp.getShort(20)); tempnna.setEpilepsia(temp.getShort(21)); tempnna.setAbuso(temp.getShort(22)); tempnna.setSifilis(temp.getShort(23)); tempnna.setSeguiMedico(temp.getShort(24)); tempnna.setOperacion(temp.getShort(25)); tempnna.setHiperactivo(temp.getShort(26)); tempnna.setEspecial(temp.getShort(27)); tempnna.setEnfermo(temp.getShort(28)); tempnna.setMayor(temp.getShort(29)); tempnna.setAdolescente(temp.getShort(30)); tempnna.setHermano(temp.getShort(31)); tempnna.setNn(temp.getShort(32)); tempnna.setObservaciones(temp.getString(33)); tempnna.setNResolAband(temp.getString(34)); tempnna.setNResolCons(temp.getString(35)); try { expnna = getExpNna(temp.getLong(1)); if (expnna.getIdexpedienteNna() != 0) { Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>(); listexp.add(expnna); tempnna.setExpedienteNnas(listexp); } } catch (Exception e) { } allNnaAux.add(tempnna); } statement.close(); temp.close(); //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO for (Nna auxnna : allNnaAux) { Set<Designacion> listDesig = new HashSet<Designacion>(); String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, auxnna.getIdnna()); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); while (rs2.next()) { desig = new Designacion(); desig.setIddesignacion(rs2.getLong(1)); desig.setNDesignacion(rs2.getString(5)); desig.setPrioridad(rs2.getLong(6)); desig.setFechaPropuesta(rs2.getDate(7)); desig.setFechaConsejo(rs2.getDate(8)); desig.setAceptacionConsejo(rs2.getShort(9)); desig.setTipoPropuesta(rs2.getString(10)); desig.setObs(rs2.getString(11)); listDesig.add(desig); } auxnna.setDesignacions(listDesig); allNna.add(auxnna); statement2.close(); rs2.close(); } for (Nna auxnna : allNna) { if (auxnna.getClasificacion().equals("prioritario")) { Set<EstudioCaso> listEst = new HashSet<EstudioCaso>(); String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, auxnna.getIdnna()); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet rs3 = (ResultSet) statement3.getObject(2); while (rs3.next()) { est = new EstudioCaso(); est.setIdestudioCaso(rs3.getLong(1)); est.setOrden(rs3.getString(4)); est.setFechaEstudio(rs3.getDate(5)); est.setFechaSolAdop(rs3.getDate(6)); est.setResultado(rs3.getString(7)); est.setPrioridad(rs3.getLong(8)); est.setNSolicitud(rs3.getLong(9)); listEst.add(est); } auxnna.setEstudioCasos(listEst); statement3.close(); rs3.close(); } allNnaFinal.add(auxnna); } //METODO BUBBLESORT PARA ORDENAR POR CODIGO if (clasif.equals("prioritario")) { Nna auxnna2; int n = allNnaFinal.size(); for (int i = 0; i < n - 1; i++) { for (int j = i; j < n - 1; j++) { if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) { if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } else { String apellidoPrev = ""; String apellidoNext = ""; try { apellidoPrev = allNnaFinal.get(i).getApellidoP(); if (apellidoPrev == null) { apellidoPrev = ""; } } catch (Exception ex) { apellidoPrev = ""; } try { apellidoNext = allNnaFinal.get(j + 1).getApellidoP(); if (apellidoNext == null) { apellidoNext = ""; } } catch (Exception ex) { apellidoNext = ""; } if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } else { Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas(); Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas(); if (!listExp2.isEmpty()) { for (ExpedienteNna exp1 : listExp1) { for (ExpedienteNna exp2 : listExp2) { String codant = exp1.getCodigoReferencia(); String codpost = exp2.getCodigoReferencia(); if (codant == null) { codant = ""; } if (codpost == null) { codpost = ""; } if (codant.compareToIgnoreCase(codpost) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } } } } } } } }; session.doWork(work); return allNnaFinal; }
From source file:org.kordamp.json.xml.XMLSerializer.java
private void setValue(JSONArray jsonArray, Element element, String defaultType) { String clazz = getClass(element); String type = getType(element); type = (type == null) ? defaultType : type; if (!skipNamespaces && hasNamespaces(element)) { jsonArray.element(simplifyValue(null, processElement(element, type))); return;/* w ww. ja va 2 s . c o m*/ } else if (element.getAttributeCount() > 0) { if (isFunction(element)) { Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params")); String[] params = null; String text = element.getValue(); params = StringUtils.split(paramsAttribute.getValue(), ","); jsonArray.element(new JSONFunction(params, text)); return; } else { jsonArray.element(simplifyValue(null, processElement(element, type))); return; } } boolean classProcessed = false; if (clazz != null) { if (clazz.compareToIgnoreCase(JSONTypes.ARRAY) == 0) { jsonArray.element(processArrayElement(element, type)); classProcessed = true; } else if (clazz.compareToIgnoreCase(JSONTypes.OBJECT) == 0) { jsonArray.element(simplifyValue(null, processObjectElement(element, type))); classProcessed = true; } } if (!classProcessed) { if (type.compareToIgnoreCase(JSONTypes.STRING) == 0) { // see if by any chance has a 'params' attribute Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params")); if (paramsAttribute != null) { String[] params = null; String text = element.getValue(); params = StringUtils.split(paramsAttribute.getValue(), ","); jsonArray.element(new JSONFunction(params, text)); } else { if (isArray(element, false)) { JSON value = processArrayElement(element, defaultType); jsonArray.element(value); } else if (isObject(element, false)) { jsonArray.element(simplifyValue(null, processObjectElement(element, defaultType))); } else { jsonArray.element(trimSpaceFromValue(element.getValue())); } } } else if (type.compareToIgnoreCase(JSONTypes.BOOLEAN) == 0) { jsonArray.element(Boolean.valueOf(element.getValue())); } else if (type.compareToIgnoreCase(JSONTypes.NUMBER) == 0) { // try integer first try { jsonArray.element(Integer.valueOf(element.getValue())); } catch (NumberFormatException e) { jsonArray.element(Double.valueOf(element.getValue())); } } else if (type.compareToIgnoreCase(JSONTypes.INTEGER) == 0) { jsonArray.element(Integer.valueOf(element.getValue())); } else if (type.compareToIgnoreCase(JSONTypes.FLOAT) == 0) { jsonArray.element(Double.valueOf(element.getValue())); } else if (type.compareToIgnoreCase(JSONTypes.FUNCTION) == 0) { String[] params = null; String text = element.getValue(); Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params")); if (paramsAttribute != null) { params = StringUtils.split(paramsAttribute.getValue(), ","); } jsonArray.element(new JSONFunction(params, text)); } } }