List of usage examples for java.util GregorianCalendar setTime
public final void setTime(Date date)
Date
. From source file:org.structr.core.entity.AbstractNode.java
@Override public GregorianCalendar getCreationDate() { final Date creationDate = getProperty(AbstractNode.createdDate); if (creationDate != null) { final GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(creationDate); return calendar; }// www.j a va2s . c o m return null; }
From source file:cz.cas.lib.proarc.common.export.mets.structure.MetsElementVisitor.java
/** * Prepares a mets FileType element for a file * * @param seq/* ww w. java2 s . c om*/ * @param metsStreamName * @return */ private FileType prepareFileType(int seq, String metsStreamName, HashMap<String, Object> fileNames, HashMap<String, String> mimeTypes, MetsContext metsContext, HashMap<String, String> outputFileNames, HashMap<String, FileMD5Info> md5InfosMap) throws MetsExportException { // String streamName = Const.streamMapping.get(metsStreamName); FileType fileType = new FileType(); fileType.setCHECKSUMTYPE("MD5"); GregorianCalendar gregory = new GregorianCalendar(); gregory.setTime(new Date()); XMLGregorianCalendar calendar; try { calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregory); } catch (DatatypeConfigurationException e1) { throw new MetsExportException("Unable to create XMLGregorianDate", false, e1); } fileType.setCREATED(calendar); fileType.setSEQ(seq); fileType.setMIMETYPE(mimeTypes.get(metsStreamName)); InputStream is = null; fileType.setID(Const.streamMappingPrefix.get(metsStreamName) + "_" + MetsUtils.removeNonAlpabetChars(metsContext.getPackageID()) + "_" + String.format("%04d", seq)); if (fileNames.get(metsStreamName) instanceof String) { String fileNameOriginal = (String) fileNames.get(metsStreamName); int lastIndex = fileNameOriginal.lastIndexOf('/'); int preLastIndex = fileNameOriginal.substring(1, lastIndex).lastIndexOf('/'); String fileName = metsContext.getPath() + fileNameOriginal.substring(preLastIndex + 2); File file = new File(fileName); try { is = new FileInputStream(file); } catch (FileNotFoundException e) { throw new MetsExportException("File not found:" + fileName, false, e); } } if (fileNames.get(metsStreamName) instanceof byte[]) { byte[] bytes = (byte[]) fileNames.get(metsStreamName); is = new ByteArrayInputStream(bytes); } if (fileNames.get(metsStreamName) instanceof InputStream) { is = (InputStream) fileNames.get(metsStreamName); } if (metsStreamName.equalsIgnoreCase("TECHMDGRP")) { is = addLabelToAmdSec(is, metsContext); } String outputFileName = fileType.getID() + "." + MimeType.getExtension(mimeTypes.get(metsStreamName)); String fullOutputFileName = metsContext.getPackageDir().getAbsolutePath() + File.separator + Const.streamMappingFile.get(metsStreamName) + File.separator + outputFileName; outputFileNames.put(metsStreamName, fullOutputFileName); try { FileMD5Info fileMD5Info; if (md5InfosMap.get(metsStreamName) == null) { fileMD5Info = MetsUtils.getDigestAndCopy(is, new FileOutputStream(fullOutputFileName)); md5InfosMap.put(metsStreamName, fileMD5Info); } else { FileMD5Info tempMd5 = MetsUtils.getDigestAndCopy(is, new FileOutputStream(fullOutputFileName)); fileMD5Info = md5InfosMap.get(metsStreamName); fileMD5Info.setSize(tempMd5.getSize()); fileMD5Info.setMd5(tempMd5.getMd5()); } fileType.setSIZE(Long.valueOf(fileMD5Info.getSize())); fileMD5Info.setFileName("." + File.separator + Const.streamMappingFile.get(metsStreamName) + File.separator + outputFileName); fileMD5Info.setMimeType(fileType.getMIMETYPE()); fileType.setCHECKSUM(fileMD5Info.getMd5()); metsContext.getFileList().add(fileMD5Info); } catch (Exception e) { throw new MetsExportException("Unable to process file " + fullOutputFileName, false, e); } FLocat flocat = new FLocat(); flocat.setLOCTYPE("URL"); String href = "." + "/" + Const.streamMappingFile.get(metsStreamName) + "/" + outputFileName; URI uri; uri = URI.create(href); flocat.setHref(uri.toASCIIString()); fileType.getFLocat().add(flocat); return fileType; }
From source file:com.autentia.tnt.bean.activity.ActivityBean.java
/** * retrieves the duration of the external activity, calculated as the difference between start time and end time * @return/*from ww w.jav a 2 s. c o m*/ */ public int getExternalActivityDuration() { GregorianCalendar startCal = new GregorianCalendar(); GregorianCalendar endCal = new GregorianCalendar(); startCal.setTime(getExternalActivityStartDate()); endCal.setTime(getExternalActivityEndDate()); int duration = (int) (endCal.getTimeInMillis() - startCal.getTimeInMillis()) / (60 * 1000); return duration; }
From source file:Logica.Usuario.java
@Override public ArrayList<informeDescargos> generarInformePorRA(String area, BigDecimal id) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); Connection con = null;//w w w . j a v a 2 s . c o m PreparedStatement ps = null; ResultSet rs = null; String statement = "select D.CINTERNO, \"-\", item.DESCRIPCION, item.CANTIDAD, sum(D.CANTIDAD), D.FECHA\n" + "from item, DESCARGO d\n" + "where item.CINTERNO = D.CINTERNO and D.ID_usuario = ?\n" + "group by D.CINTERNO, item.DESCRIPCION, item.CANTIDAD, D.FECHA"; informeDescargos fila = null; System.out.println(statement); ArrayList<informeDescargos> listado = new ArrayList<>(); try { con = Conexion.conexion.getConnection(); ps = con.prepareStatement(statement); ps.setBigDecimal(1, id); rs = ps.executeQuery(); while (rs.next()) { GregorianCalendar c = new GregorianCalendar(); c.setTime(rs.getDate(6)); fila = new informeDescargos(rs.getString(1), rs.getString(2), rs.getString(3), rs.getFloat(4), rs.getFloat(5), c); listado.add(fila); } } catch (SQLException ex) { Logger.getLogger(Usuario.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (ps != null) { ps.close(); } if (rs != null) { rs.close(); } if (con != null) { con.close(); } } catch (SQLException ex) { System.out.println("Error cerrando conexion"); } } return listado; }
From source file:org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService.java
/** * Gets object data for a log entry, or null if skipped. *//*from w w w .j a v a 2s. com*/ protected ObjectData getLogEntryObjectData(LogEntry logEntry) { String docType = logEntry.getDocType(); if (!repository.hasType(docType)) { // ignore types present in the log but not exposed through CMIS return null; } // change type String eventId = logEntry.getEventId(); ChangeType changeType; if (DOCUMENT_CREATED.equals(eventId)) { changeType = ChangeType.CREATED; } else if (DOCUMENT_UPDATED.equals(eventId)) { changeType = ChangeType.UPDATED; } else if (DOCUMENT_REMOVED.equals(eventId)) { changeType = ChangeType.DELETED; } else { return null; } ChangeEventInfoDataImpl cei = new ChangeEventInfoDataImpl(); cei.setChangeType(changeType); // change time GregorianCalendar changeTime = (GregorianCalendar) Calendar.getInstance(); Date date = logEntry.getEventDate(); changeTime.setTime(date); cei.setChangeTime(changeTime); ObjectDataImpl od = new ObjectDataImpl(); od.setChangeEventInfo(cei); // properties: id, doc type PropertiesImpl properties = new PropertiesImpl(); properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_ID, logEntry.getDocUUID())); properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, docType)); od.setProperties(properties); return od; }
From source file:com.zoho.creator.jframework.XMLParser.java
private static void parseAndSetCalendarRecords(ZCView zcView, Node calendarNode) { zcView.setGrouped(true);/* w w w.java 2s .c o m*/ NodeList eventsList = calendarNode.getChildNodes(); int year = zcView.getRecordsMonthYear().getTwo() - 1900; int month = zcView.getRecordsMonthYear().getOne(); GregorianCalendar cureentmnthcalendar = new GregorianCalendar(); Date currentDate = new Date(); for (int i = 0; i < eventsList.getLength(); i++) { Node eventNode = eventsList.item(i); NamedNodeMap eventAttrMap = eventNode.getAttributes(); long recordid = Long.parseLong(eventAttrMap.getNamedItem("id").getNodeValue()); //No I18N String title = getChildNodeValue(eventNode, "title"); //eventAttrMap.getNamedItem("title").getNodeValue(); //No I18N boolean isAllDay = Boolean.parseBoolean(eventAttrMap.getNamedItem("allDay").getNodeValue()); //No I18N // 07/31/2013 08:00:00 String dateFormat = "MM/dd/yyyy HH:mm:ss"; //No I18N if (isAllDay) { dateFormat = "MM/dd/yyyy"; //No I18N } Date startTime = getDateValue(eventAttrMap.getNamedItem("start").getNodeValue(), dateFormat); //No I18N ZCRecord record = zcView.getRecord(recordid); record.setEventTitle(title); if (isAllDay) { zcView.setIsAllDay(isAllDay); Node endNode = eventAttrMap.getNamedItem("end");//No I18N Date endTime = null; if (endNode != null) { endTime = getDateValue(endNode.getNodeValue(), dateFormat); } int startDay = -1; if (startTime != null) { startDay = startTime.getDate(); } int endDay = -1; if (endTime != null) { endDay = endTime.getDate(); } if (endDay != -1) { currentDate.setDate(1); currentDate.setMonth(month); currentDate.setYear(year); currentDate.setMinutes(0); currentDate.setHours(0); currentDate.setSeconds(0); cureentmnthcalendar.setTime(currentDate); cureentmnthcalendar.add(cureentmnthcalendar.DAY_OF_MONTH, -6); currentDate = cureentmnthcalendar.getTime(); for (int j = 0; j < 42; j++) { if ((currentDate.getDate() == startTime.getDate() && currentDate.getMonth() == startTime.getMonth() && currentDate.getYear() == startTime.getYear()) || (currentDate.after(startTime) && currentDate.before(endTime)) || (currentDate.getDate() == endTime.getDate() && currentDate.getMonth() == endTime.getMonth() && currentDate.getYear() == endTime.getYear())) { zcView.setEvent(record, currentDate); } cureentmnthcalendar.add(cureentmnthcalendar.DAY_OF_MONTH, 1); currentDate = cureentmnthcalendar.getTime(); } //Collections.sort(eventRecords); } record.setEventDate(startTime); } else { // 07/31/2013 08:00:00 Date endTime = getDateValue(eventAttrMap.getNamedItem("end").getNodeValue(), dateFormat); //No I18N record.setStartTime(startTime); record.setEndTime(endTime); Calendar startCalendar = new GregorianCalendar(); startCalendar.setTime(startTime); startCalendar.set(Calendar.HOUR_OF_DAY, 0); startCalendar.set(Calendar.MINUTE, 0); startCalendar.set(Calendar.SECOND, 0); startCalendar.set(Calendar.MILLISECOND, 0); Calendar endCalendar = new GregorianCalendar(); endCalendar.setTime(endTime); endCalendar.set(Calendar.HOUR_OF_DAY, 0); endCalendar.set(Calendar.MINUTE, 0); endCalendar.set(Calendar.SECOND, 0); endCalendar.set(Calendar.MILLISECOND, 0); Date eventDate = new Date(startCalendar.getTimeInMillis()); zcView.setEvent(record, eventDate); while ((startCalendar.get(Calendar.YEAR) != endCalendar.get(Calendar.YEAR)) || (startCalendar.get(Calendar.MONTH) != endCalendar.get(Calendar.MONTH)) || (startCalendar.get(Calendar.DATE) != endCalendar.get(Calendar.DATE))) { startCalendar.add(Calendar.DATE, 1); eventDate = new Date(startCalendar.getTimeInMillis()); zcView.setEvent(record, eventDate); } } } List<ZCGroup> zcGroups = zcView.getGroups(); HashMap<Date, List<ZCRecord>> eventsMap = zcView.getEventRecordsMap(); SortedSet<Date> keys = new TreeSet<Date>(eventsMap.keySet()); for (Date eventDate : keys) { List<ZCRecord> eventRecords = eventsMap.get(eventDate); List<String> groupHeaderValues = new ArrayList<String>(); SimpleDateFormat dateFormat = new SimpleDateFormat(zcView.getDateFormat()); //No I18N groupHeaderValues.add(dateFormat.format(eventDate)); ZCGroup zcGroup = new ZCGroup(groupHeaderValues); zcGroups.add(zcGroup); for (int i = 0; i < eventRecords.size(); i++) { ZCRecord eventRecord = eventRecords.get(i); zcGroup.addRecord(eventRecord); } } zcView.sortRecordsForCalendar(); }
From source file:org.exoplatform.contact.service.impl.JCRDataStorage.java
private Node setContactNodeProperties(Node contactNode, Contact contact) throws Exception { contactNode.setProperty("exo:fullName", contact.getFullName()); contactNode.setProperty("exo:firstName", contact.getFirstName()); contactNode.setProperty("exo:lastName", contact.getLastName()); contactNode.setProperty("exo:nickName", contact.getNickName()); contactNode.setProperty("exo:gender", contact.getGender()); GregorianCalendar dateTime = new GregorianCalendar(); Date birthday = contact.getBirthday(); if (birthday != null) { dateTime.setTime(birthday); contactNode.setProperty("exo:birthday", dateTime); } else//from www.j a v a 2 s. co m try { contactNode.getProperty("exo:birthday").remove(); } catch (PathNotFoundException e) { } contactNode.setProperty("exo:jobTitle", contact.getJobTitle()); if (contact.getEmailAddresses() == null || contact.getEmailAddress().length() == 0) contactNode.setProperty("exo:emailAddress", new String[] { "" }); else contactNode.setProperty("exo:emailAddress", contact.getEmailAddresses().toArray(new String[] {})); contactNode.setProperty("exo:exoId", contact.getExoId()); contactNode.setProperty("exo:googleId", contact.getGoogleId()); contactNode.setProperty("exo:msnId", contact.getMsnId()); contactNode.setProperty("exo:aolId", contact.getAolId()); contactNode.setProperty("exo:yahooId", contact.getYahooId()); contactNode.setProperty("exo:icrId", contact.getIcrId()); contactNode.setProperty("exo:skypeId", contact.getSkypeId()); contactNode.setProperty("exo:icqId", contact.getIcqId()); contactNode.setProperty("exo:homeAddress", contact.getHomeAddress()); contactNode.setProperty("exo:homeCity", contact.getHomeCity()); contactNode.setProperty("exo:homeState_province", contact.getHomeState_province()); contactNode.setProperty("exo:homePostalCode", contact.getHomePostalCode()); contactNode.setProperty("exo:homeCountry", contact.getHomeCountry()); contactNode.setProperty("exo:homePhone1", contact.getHomePhone1()); contactNode.setProperty("exo:homePhone2", contact.getHomePhone2()); contactNode.setProperty("exo:homeFax", contact.getHomeFax()); contactNode.setProperty("exo:personalSite", contact.getPersonalSite()); contactNode.setProperty("exo:workAddress", contact.getWorkAddress()); contactNode.setProperty("exo:workCity", contact.getWorkCity()); contactNode.setProperty("exo:workState_province", contact.getWorkStateProvince()); contactNode.setProperty("exo:workPostalCode", contact.getWorkPostalCode()); contactNode.setProperty("exo:workCountry", contact.getWorkCountry()); contactNode.setProperty("exo:workPhone1", contact.getWorkPhone1()); contactNode.setProperty("exo:workPhone2", contact.getWorkPhone2()); contactNode.setProperty("exo:workFax", contact.getWorkFax()); contactNode.setProperty("exo:mobilePhone", contact.getMobilePhone()); contactNode.setProperty("exo:webPage", contact.getWebPage()); contactNode.setProperty("exo:note", contact.getNote()); contactNode.setProperty(PROP_ADDRESSBOOK_REFS, contact.getAddressBookIds()); contactNode.setProperty("exo:tags", contact.getTags()); contactNode.setProperty("exo:editPermissionUsers", contact.getEditPermissionUsers()); contactNode.setProperty("exo:viewPermissionUsers", contact.getViewPermissionUsers()); contactNode.setProperty("exo:editPermissionGroups", contact.getEditPermissionGroups()); contactNode.setProperty("exo:viewPermissionGroups", contact.getViewPermissionGroups()); if (contact.getLastUpdated() != null) { dateTime.setTime(contact.getLastUpdated()); contactNode.setProperty("exo:lastUpdated", dateTime); } // save image to contact ContactAttachment attachment = contact.getAttachment(); if (attachment != null) { // fix load image on IE6 UI ExtendedNode extNode = (ExtendedNode) contactNode; if (extNode.canAddMixin("exo:privilegeable")) extNode.addMixin("exo:privilegeable"); String[] arrayPers = { PermissionType.READ, PermissionType.ADD_NODE, PermissionType.SET_PROPERTY, PermissionType.REMOVE }; extNode.setPermission(SystemIdentity.ANY, arrayPers); List<AccessControlEntry> permsList = extNode.getACL().getPermissionEntries(); for (AccessControlEntry accessControlEntry : permsList) { extNode.setPermission(accessControlEntry.getIdentity(), arrayPers); } if (attachment.getFileName() != null) { Node nodeFile = null; try { nodeFile = contactNode.getNode("image"); } catch (PathNotFoundException ex) { nodeFile = contactNode.addNode("image", "nt:file"); } Node nodeContent = null; try { nodeContent = nodeFile.getNode("jcr:content"); } catch (PathNotFoundException ex) { nodeContent = nodeFile.addNode("jcr:content", "nt:resource"); } nodeContent.setProperty("jcr:mimeType", attachment.getMimeType()); nodeContent.setProperty("jcr:data", attachment.getInputStream()); nodeContent.setProperty("jcr:lastModified", Calendar.getInstance().getTimeInMillis()); } } else { if (contactNode.hasNode("image")) contactNode.getNode("image").remove(); } return contactNode; }
From source file:br.com.upic.camel.openedge.OpenEdgeEndpoint.java
@Override protected void onExchange(final Exchange exchange) throws Exception { try {/* www. j a v a2s . c o m*/ LOG.info("Unmarshalling the request"); final Request req = (Request) unmarshaller.unmarshal(exchange.getIn().getBody(Document.class)); LOG.info("Setting the input params"); final List<JAXBElement<? extends Serializable>> reqParamElementList = req.getParamElementList(); final ParamArray proParams = new ParamArray(reqParamElementList.size()); for (final JAXBElement<? extends Serializable> reqParamElement : reqParamElementList) { final Serializable reqParam = reqParamElement.getValue(); if (reqParam instanceof CharArrayParam) { final CharArrayParam charArrayParam = (CharArrayParam) reqParam; final ParamMode mode = charArrayParam.getMode(); final int id = charArrayParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final List<String> value = new ArrayList<String>(); for (final JAXBElement<String> valueElement : charArrayParam.getValueElementList()) { if (!valueElement.isNil()) value.add(DatatypeConverter.parseString(valueElement.getValue())); else value.add(null); } proParams.addCharacterArray(id, value.toArray(new String[] {}), mode.value(), value.size()); } else { proParams.addCharacterArray(id, null, mode.value(), 0); } } else if (reqParam instanceof CharParam) { final CharParam charParam = (CharParam) reqParam; final ParamMode mode = charParam.getMode(); final int id = charParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) proParams.addCharacter(id, DatatypeConverter.parseString(charParam.getContent()), mode.value()); else proParams.addCharacter(id, null, mode.value()); } else if (reqParam instanceof DateArrayParam) { final DateArrayParam dateArrayParam = (DateArrayParam) reqParam; final ParamMode mode = dateArrayParam.getMode(); final int id = dateArrayParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final List<GregorianCalendar> value = new ArrayList<GregorianCalendar>(); for (final JAXBElement<String> valueElement : dateArrayParam.getValueElementList()) { if (!valueElement.isNil()) { final GregorianCalendar cal = new GregorianCalendar(); cal.setTime(DatatypeConverter.parseDate(valueElement.getValue()).getTime()); value.add(cal); } else { value.add(null); } } proParams.addDateArray(id, value.toArray(new GregorianCalendar[] {}), mode.value(), value.size()); } else { proParams.addDateArray(id, null, mode.value(), 0); } } else if (reqParam instanceof DateParam) { final DateParam dateParam = (DateParam) reqParam; final ParamMode mode = dateParam.getMode(); final int id = dateParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final GregorianCalendar cal = new GregorianCalendar(); cal.setTime(DatatypeConverter.parseDate(dateParam.getContent()).getTime()); proParams.addDate(id, cal, mode.value()); } else { proParams.addDate(id, null, mode.value()); } } else if (reqParam instanceof DateTimeArrayParam) { final DateTimeArrayParam dateTimeArrayParam = (DateTimeArrayParam) reqParam; final ParamMode mode = dateTimeArrayParam.getMode(); final int id = dateTimeArrayParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final List<GregorianCalendar> value = new ArrayList<GregorianCalendar>(); for (final JAXBElement<String> valueElement : dateTimeArrayParam.getValueElementList()) { if (!valueElement.isNil()) { final GregorianCalendar cal = new GregorianCalendar(); cal.setTime(DatatypeConverter.parseDateTime(valueElement.getValue()).getTime()); value.add(cal); } else { value.add(null); } } proParams.addDatetimeArray(id, value.toArray(new GregorianCalendar[] {}), mode.value(), value.size()); } else { proParams.addDatetimeArray(id, null, mode.value(), 0); } } else if (reqParam instanceof DateTimeParam) { final DateTimeParam dateTimeParam = (DateTimeParam) reqParam; final ParamMode mode = dateTimeParam.getMode(); final int id = dateTimeParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final GregorianCalendar cal = new GregorianCalendar(); cal.setTime(DatatypeConverter.parseDateTime(dateTimeParam.getContent()).getTime()); proParams.addDatetime(id, cal, mode.value()); } else { proParams.addDatetime(id, null, mode.value()); } } else if (reqParam instanceof DateTimeTZArrayParam) { final DateTimeTZArrayParam dateTimeTZArrayParam = (DateTimeTZArrayParam) reqParam; final ParamMode mode = dateTimeTZArrayParam.getMode(); final int id = dateTimeTZArrayParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final List<GregorianCalendar> value = new ArrayList<GregorianCalendar>(); for (final JAXBElement<String> valueElement : dateTimeTZArrayParam.getValueElementList()) { if (!valueElement.isNil()) { final GregorianCalendar cal = new GregorianCalendar(); cal.setTime(DatatypeConverter.parseDateTime(valueElement.getValue()).getTime()); value.add(cal); } else { value.add(null); } } proParams.addDatetimeTZArray(id, value.toArray(new GregorianCalendar[] {}), mode.value(), value.size()); } else { proParams.addDatetimeTZArray(id, null, mode.value(), 0); } } else if (reqParam instanceof DateTimeTZParam) { final DateTimeTZParam dateTimeTZParam = (DateTimeTZParam) reqParam; final ParamMode mode = dateTimeTZParam.getMode(); final int id = dateTimeTZParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final GregorianCalendar cal = new GregorianCalendar(); cal.setTime(DatatypeConverter.parseDateTime(dateTimeTZParam.getContent()).getTime()); proParams.addDatetimeTZ(id, cal, mode.value()); } else { proParams.addDatetimeTZ(id, null, mode.value()); } } else if (reqParam instanceof DecArrayParam) { final DecArrayParam decArrayParam = (DecArrayParam) reqParam; final ParamMode mode = decArrayParam.getMode(); final int id = decArrayParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final List<BigDecimal> value = new ArrayList<BigDecimal>(); for (final JAXBElement<String> valueElement : decArrayParam.getValueElementList()) { if (!valueElement.isNil()) value.add(DatatypeConverter.parseDecimal(valueElement.getValue())); else value.add(null); } proParams.addDecimalArray(id, value.toArray(new BigDecimal[] {}), mode.value(), value.size()); } else { proParams.addDecimalArray(id, null, mode.value(), 0); } } else if (reqParam instanceof DecParam) { final DecParam decParam = (DecParam) reqParam; final ParamMode mode = decParam.getMode(); final int id = decParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) proParams.addDecimal(id, DatatypeConverter.parseDecimal(decParam.getContent()), mode.value()); else proParams.addDecimal(id, null, mode.value()); } else if (reqParam instanceof IntArrayParam) { final IntArrayParam intArrayParam = (IntArrayParam) reqParam; final ParamMode mode = intArrayParam.getMode(); final int id = intArrayParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final List<Integer> value = new ArrayList<Integer>(); for (final JAXBElement<String> valueElement : intArrayParam.getValueElementList()) { if (!valueElement.isNil()) value.add(DatatypeConverter.parseInt(valueElement.getValue())); else value.add(null); } proParams.addIntegerArray(id, value.toArray(new Integer[] {}), mode.value(), value.size()); } else { proParams.addIntegerArray(id, (Integer[]) null, mode.value(), 0); } } else if (reqParam instanceof IntParam) { final IntParam intParam = (IntParam) reqParam; final ParamMode mode = intParam.getMode(); final int id = intParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) proParams.addInteger(id, new Integer(DatatypeConverter.parseInt(intParam.getContent())), mode.value()); else proParams.addInteger(id, null, mode.value()); } else if (reqParam instanceof LogArrayParam) { final LogArrayParam logArrayParam = (LogArrayParam) reqParam; final ParamMode mode = logArrayParam.getMode(); final int id = logArrayParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) { final List<Boolean> value = new ArrayList<Boolean>(); for (final JAXBElement<String> valueElement : logArrayParam.getValueElementList()) { if (!valueElement.isNil()) value.add(DatatypeConverter.parseBoolean(valueElement.getValue())); else value.add(null); } proParams.addLogicalArray(id, value.toArray(new Boolean[] {}), mode.value(), value.size()); } else { proParams.addLogicalArray(id, (Boolean[]) null, mode.value(), 0); } } else if (reqParam instanceof LogParam) { final LogParam logParam = (LogParam) reqParam; final ParamMode mode = logParam.getMode(); final int id = logParam.getId(); if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) proParams.addLogical(id, new Boolean(DatatypeConverter.parseBoolean(logParam.getContent())), mode.value()); else proParams.addLogical(id, null, mode.value()); } else if (reqParam instanceof ResultSetParam) { final ResultSetParam rsParam = (ResultSetParam) reqParam; final ParamMode mode = rsParam.getMode(); final int id = rsParam.getId(); final ResultSetMetaData rsMetaData = rsParam.getResultSetMetaData(); final List<Serializable> fieldMetaDataList = rsMetaData.getFieldMetaDataList(); final ProResultSetMetaDataImpl proRsMetaData = new ProResultSetMetaDataImpl( fieldMetaDataList.size()); for (final Serializable fieldMetaData : fieldMetaDataList) { if (fieldMetaData instanceof CharFieldMetaData) { final CharFieldMetaData charFieldMetaData = (CharFieldMetaData) fieldMetaData; proRsMetaData.setFieldMetaData(charFieldMetaData.getId(), charFieldMetaData.getName(), charFieldMetaData.getExtent(), Parameter.PRO_CHARACTER); } else if (fieldMetaData instanceof DateFieldMetaData) { final DateFieldMetaData dateFieldMetaData = (DateFieldMetaData) fieldMetaData; proRsMetaData.setFieldMetaData(dateFieldMetaData.getId(), dateFieldMetaData.getName(), dateFieldMetaData.getExtent(), Parameter.PRO_DATE); } else if (fieldMetaData instanceof DateTimeFieldMetaData) { final DateTimeFieldMetaData dateTimeFieldMetaData = (DateTimeFieldMetaData) fieldMetaData; proRsMetaData.setFieldMetaData(dateTimeFieldMetaData.getId(), dateTimeFieldMetaData.getName(), dateTimeFieldMetaData.getExtent(), Parameter.PRO_DATETIME); } else if (fieldMetaData instanceof DateTimeTZFieldMetaData) { final DateTimeTZFieldMetaData dateTimeTZFieldMetaData = (DateTimeTZFieldMetaData) fieldMetaData; proRsMetaData.setFieldMetaData(dateTimeTZFieldMetaData.getId(), dateTimeTZFieldMetaData.getName(), dateTimeTZFieldMetaData.getExtent(), Parameter.PRO_DATETIMETZ); } else if (fieldMetaData instanceof DecFieldMetaData) { final DecFieldMetaData decFieldMetaData = (DecFieldMetaData) fieldMetaData; proRsMetaData.setFieldMetaData(decFieldMetaData.getId(), decFieldMetaData.getName(), decFieldMetaData.getExtent(), Parameter.PRO_DECIMAL); } else if (fieldMetaData instanceof IntFieldMetaData) { final IntFieldMetaData intFieldMetaData = (IntFieldMetaData) fieldMetaData; proRsMetaData.setFieldMetaData(intFieldMetaData.getId(), intFieldMetaData.getName(), intFieldMetaData.getExtent(), Parameter.PRO_INTEGER); } else if (fieldMetaData instanceof LogFieldMetaData) { final LogFieldMetaData logFieldMetaData = (LogFieldMetaData) fieldMetaData; proRsMetaData.setFieldMetaData(logFieldMetaData.getId(), logFieldMetaData.getName(), logFieldMetaData.getExtent(), Parameter.PRO_LOGICAL); } } if (((ParamMode.INPUT == mode) || (ParamMode.INPUT_OUTPUT == mode)) && (!reqParamElement.isNil())) proParams.addTable(id, new OpenEdgeResultSet(rsParam.getRowList().iterator()), mode.value(), proRsMetaData); else proParams.addTable(id, null, mode.value(), proRsMetaData); } } LOG.info("Connecting to the AppServer"); if (SESSION_MODEL_MANAGED == sessionModel) RunTimeProperties.setSessionModel(0); else if (SESSION_MODEL_FREE == sessionModel) RunTimeProperties.setSessionModel(1); final OpenAppObject proAppObject = new OpenAppObject(url, user, password, null, null); proAppObject.runProc(req.getProgram(), proParams); LOG.info("Marshalling the response"); final Response res = OBJECT_FACTORY.createResponse(); res.setResult(proParams.getProcReturnString()); LOG.info("Setting the output params"); for (final JAXBElement<? extends Serializable> reqParamElement : reqParamElementList) { final Serializable reqParam = reqParamElement.getValue(); if (reqParam instanceof CharArrayParam) { final CharArrayParam reqCharArrayParam = (CharArrayParam) reqParam; if (ParamMode.INPUT != reqCharArrayParam.getMode()) { final JAXBElement<CharArrayParam> resParamElement = new JAXBElement<CharArrayParam>( new QName(NS, "CharArray"), CharArrayParam.class, null); final CharArrayParam resParam = OBJECT_FACTORY.createCharArrayParam(); resParam.setId(reqCharArrayParam.getId()); resParam.setName(reqCharArrayParam.getName()); final String[] proParam = (String[]) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { for (int i = 0; i < proParam.length; i++) { final JAXBElement<String> valueElement = new JAXBElement<String>( new QName(NS, "Value"), String.class, null); if (proParam[i] != null) valueElement.setValue(DatatypeConverter.printString(proParam[i])); else valueElement.setNil(true); resParam.getValueElementList().add(valueElement); } resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof CharParam) { final CharParam reqCharParam = (CharParam) reqParam; if (ParamMode.INPUT != reqCharParam.getMode()) { final JAXBElement<CharParam> resParamElement = new JAXBElement<CharParam>( new QName(NS, "Char"), CharParam.class, null); final CharParam resParam = OBJECT_FACTORY.createCharParam(); resParam.setId(reqCharParam.getId()); resParam.setName(reqCharParam.getName()); final String proParam = (String) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { resParam.setContent(DatatypeConverter.printString(proParam)); resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof DateArrayParam) { final DateArrayParam reqDateArrayParam = (DateArrayParam) reqParam; if (ParamMode.INPUT != reqDateArrayParam.getMode()) { final JAXBElement<DateArrayParam> resParamElement = new JAXBElement<DateArrayParam>( new QName(NS, "DateArray"), DateArrayParam.class, null); final DateArrayParam resParam = OBJECT_FACTORY.createDateArrayParam(); resParam.setId(reqDateArrayParam.getId()); resParam.setName(reqDateArrayParam.getName()); final Date[] proParam = (Date[]) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { for (int i = 0; i < proParam.length; i++) { final JAXBElement<String> valueElement = new JAXBElement<String>( new QName(NS, "Value"), String.class, null); if (proParam[i] != null) { final Calendar cal = Calendar.getInstance(); cal.setTime(proParam[i]); valueElement.setValue(DatatypeConverter.printDate(cal)); } else { valueElement.setNil(true); } resParam.getValueElementList().add(valueElement); } resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof DateParam) { final DateParam reqDateParam = (DateParam) reqParam; if (ParamMode.INPUT != reqDateParam.getMode()) { final JAXBElement<DateParam> resParamElement = new JAXBElement<DateParam>( new QName(NS, "Date"), DateParam.class, null); final DateParam resParam = OBJECT_FACTORY.createDateParam(); resParam.setId(reqDateParam.getId()); resParam.setName(reqDateParam.getName()); final Date proParam = (Date) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { final Calendar cal = Calendar.getInstance(); cal.setTime(proParam); resParam.setContent(DatatypeConverter.printDate(cal)); resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof DateTimeArrayParam) { final DateTimeArrayParam reqDateTimeArrayParam = (DateTimeArrayParam) reqParam; if (ParamMode.INPUT != reqDateTimeArrayParam.getMode()) { final JAXBElement<DateTimeArrayParam> resParamElement = new JAXBElement<DateTimeArrayParam>( new QName(NS, "DateTimeArray"), DateTimeArrayParam.class, null); final DateTimeArrayParam resParam = OBJECT_FACTORY.createDateTimeArrayParam(); resParam.setId(reqDateTimeArrayParam.getId()); resParam.setName(reqDateTimeArrayParam.getName()); final GregorianCalendar[] proParam = (GregorianCalendar[]) proParams .getOutputParameter(resParam.getId()); if (proParam != null) { for (int i = 0; i < proParam.length; i++) { final JAXBElement<String> valueElement = new JAXBElement<String>( new QName(NS, "Value"), String.class, null); if (proParam[i] != null) valueElement.setValue(DatatypeConverter.printDateTime(proParam[i])); else valueElement.setNil(true); resParam.getValueElementList().add(valueElement); } resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof DateTimeParam) { final DateTimeParam reqDateTimeParam = (DateTimeParam) reqParam; if (ParamMode.INPUT != reqDateTimeParam.getMode()) { final JAXBElement<DateTimeParam> resParamElement = new JAXBElement<DateTimeParam>( new QName(NS, "DateTime"), DateTimeParam.class, null); final DateTimeParam resParam = OBJECT_FACTORY.createDateTimeParam(); resParam.setId(reqDateTimeParam.getId()); resParam.setName(reqDateTimeParam.getName()); final GregorianCalendar proParam = (GregorianCalendar) proParams .getOutputParameter(resParam.getId()); if (proParam != null) { resParam.setContent(DatatypeConverter.printDateTime(proParam)); resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof DateTimeTZArrayParam) { final DateTimeTZArrayParam reqDateTimeTZArrayParam = (DateTimeTZArrayParam) reqParam; if (ParamMode.INPUT != reqDateTimeTZArrayParam.getMode()) { final JAXBElement<DateTimeTZArrayParam> resParamElement = new JAXBElement<DateTimeTZArrayParam>( new QName(NS, "DateTimeTZArray"), DateTimeTZArrayParam.class, null); final DateTimeTZArrayParam resParam = OBJECT_FACTORY.createDateTimeTZArrayParam(); resParam.setId(reqDateTimeTZArrayParam.getId()); resParam.setName(reqDateTimeTZArrayParam.getName()); final GregorianCalendar[] proParam = (GregorianCalendar[]) proParams .getOutputParameter(resParam.getId()); if (proParam != null) { for (int i = 0; i < proParam.length; i++) { final JAXBElement<String> valueElement = new JAXBElement<String>( new QName(NS, "Value"), String.class, null); if (proParam[i] != null) valueElement.setValue(DatatypeConverter.printDateTime(proParam[i])); else valueElement.setNil(true); resParam.getValueElementList().add(valueElement); } resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof DateTimeTZParam) { final DateTimeTZParam reqDateTimeTZParam = (DateTimeTZParam) reqParam; if (ParamMode.INPUT != reqDateTimeTZParam.getMode()) { final JAXBElement<DateTimeTZParam> resParamElement = new JAXBElement<DateTimeTZParam>( new QName(NS, "DateTimeTZ"), DateTimeTZParam.class, null); final DateTimeTZParam resParam = OBJECT_FACTORY.createDateTimeTZParam(); resParam.setId(reqDateTimeTZParam.getId()); resParam.setName(reqDateTimeTZParam.getName()); final GregorianCalendar proParam = (GregorianCalendar) proParams .getOutputParameter(resParam.getId()); if (proParam != null) { resParam.setContent(DatatypeConverter.printDateTime(proParam)); resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof DecArrayParam) { final DecArrayParam reqDecArrayParam = (DecArrayParam) reqParam; if (ParamMode.INPUT != reqDecArrayParam.getMode()) { final JAXBElement<DecArrayParam> resParamElement = new JAXBElement<DecArrayParam>( new QName(NS, "DecArray"), DecArrayParam.class, null); final DecArrayParam resParam = OBJECT_FACTORY.createDecArrayParam(); resParam.setId(reqDecArrayParam.getId()); resParam.setName(reqDecArrayParam.getName()); final BigDecimal[] proParam = (BigDecimal[]) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { for (int i = 0; i < proParam.length; i++) { final JAXBElement<String> valueElement = new JAXBElement<String>( new QName(NS, "Value"), String.class, null); if (proParam[i] != null) valueElement.setValue(DatatypeConverter.printDecimal(proParam[i])); else valueElement.setNil(true); resParam.getValueElementList().add(valueElement); } resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof DecParam) { final DecParam reqDecParam = (DecParam) reqParam; if (ParamMode.INPUT != reqDecParam.getMode()) { final JAXBElement<DecParam> resParamElement = new JAXBElement<DecParam>( new QName(NS, "Dec"), DecParam.class, null); final DecParam resParam = OBJECT_FACTORY.createDecParam(); resParam.setId(reqDecParam.getId()); resParam.setName(reqDecParam.getName()); final BigDecimal proParam = (BigDecimal) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { resParam.setContent(DatatypeConverter.printDecimal(proParam)); resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof IntArrayParam) { final IntArrayParam reqIntArrayParam = (IntArrayParam) reqParam; if (ParamMode.INPUT != reqIntArrayParam.getMode()) { final JAXBElement<IntArrayParam> resParamElement = new JAXBElement<IntArrayParam>( new QName(NS, "IntArray"), IntArrayParam.class, null); final IntArrayParam resParam = OBJECT_FACTORY.createIntArrayParam(); resParam.setId(reqIntArrayParam.getId()); resParam.setName(reqIntArrayParam.getName()); final Integer[] proParam = (Integer[]) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { for (int i = 0; i < proParam.length; i++) { final JAXBElement<String> valueElement = new JAXBElement<String>( new QName(NS, "Value"), String.class, null); if (proParam[i] != null) valueElement.setValue(DatatypeConverter.printInt(proParam[i])); else valueElement.setNil(true); resParam.getValueElementList().add(valueElement); } resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof IntParam) { final IntParam reqIntParam = (IntParam) reqParam; if (ParamMode.INPUT != reqIntParam.getMode()) { final JAXBElement<IntParam> resParamElement = new JAXBElement<IntParam>( new QName(NS, "Int"), IntParam.class, null); final IntParam resParam = OBJECT_FACTORY.createIntParam(); resParam.setId(reqIntParam.getId()); resParam.setName(reqIntParam.getName()); final Integer proParam = (Integer) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { resParam.setContent(DatatypeConverter.printInt(proParam)); resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof LogArrayParam) { final LogArrayParam reqLogArrayParam = (LogArrayParam) reqParam; if (ParamMode.INPUT != reqLogArrayParam.getMode()) { final JAXBElement<LogArrayParam> resParamElement = new JAXBElement<LogArrayParam>( new QName(NS, "LogArray"), LogArrayParam.class, null); final LogArrayParam resParam = OBJECT_FACTORY.createLogArrayParam(); resParam.setId(reqLogArrayParam.getId()); resParam.setName(reqLogArrayParam.getName()); final Boolean[] proParam = (Boolean[]) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { for (int i = 0; i < proParam.length; i++) { final JAXBElement<String> valueElement = new JAXBElement<String>( new QName(NS, "Value"), String.class, null); if (proParam[i] != null) valueElement.setValue(DatatypeConverter.printBoolean(proParam[i])); else valueElement.setNil(true); resParam.getValueElementList().add(valueElement); } resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof LogParam) { final LogParam reqLogParam = (LogParam) reqParam; if (ParamMode.INPUT != reqLogParam.getMode()) { final JAXBElement<LogParam> resParamElement = new JAXBElement<LogParam>( new QName(NS, "Log"), LogParam.class, null); final LogParam resParam = OBJECT_FACTORY.createLogParam(); resParam.setId(reqLogParam.getId()); resParam.setName(reqLogParam.getName()); final Boolean proParam = (Boolean) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { resParam.setContent(DatatypeConverter.printBoolean(proParam)); resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } else if (reqParam instanceof ResultSetParam) { final ResultSetParam reqResultSetParam = (ResultSetParam) reqParam; if (ParamMode.INPUT != reqResultSetParam.getMode()) { final JAXBElement<ResultSetParam> resParamElement = new JAXBElement<ResultSetParam>( new QName(NS, "ResultSet"), ResultSetParam.class, null); final ResultSetParam resParam = OBJECT_FACTORY.createResultSetParam(); resParam.setId(reqResultSetParam.getId()); resParam.setName(reqResultSetParam.getName()); final ProResultSet proParam = (ProResultSet) proParams.getOutputParameter(resParam.getId()); if (proParam != null) { while (proParam.next()) { final Row row = OBJECT_FACTORY.createRow(); final ResultSetMetaData rsMetaData = reqResultSetParam.getResultSetMetaData(); for (final Serializable fieldMetaData : rsMetaData.getFieldMetaDataList()) { if (fieldMetaData instanceof CharFieldMetaData) { final CharFieldMetaData charFieldMetaData = (CharFieldMetaData) fieldMetaData; final int extent = charFieldMetaData.getExtent(); if (extent < 1) { final JAXBElement<CharField> fieldElement = new JAXBElement<CharField>( new QName(NS, "Char"), CharField.class, null); final CharField field = OBJECT_FACTORY.createCharField(); field.setId(charFieldMetaData.getId()); field.setName(charFieldMetaData.getName()); final String value = proParam.getString(field.getId()); if (value != null) { field.setContent(DatatypeConverter.printString(value)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } else { for (int i = 1; i <= extent; i++) { final JAXBElement<CharField> fieldElement = new JAXBElement<CharField>( new QName(NS, "Char"), CharField.class, null); final CharField field = OBJECT_FACTORY.createCharField(); field.setId(charFieldMetaData.getId()); field.setName(charFieldMetaData.getName()); final String value = proParam.getString(field.getId(), i); if (value != null) { field.setContent(DatatypeConverter.printString(value)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } } } else if (fieldMetaData instanceof DateFieldMetaData) { final DateFieldMetaData dateFieldMetaData = (DateFieldMetaData) fieldMetaData; final int extent = dateFieldMetaData.getExtent(); if (extent < 1) { final JAXBElement<DateField> fieldElement = new JAXBElement<DateField>( new QName(NS, "Date"), DateField.class, null); final DateField field = OBJECT_FACTORY.createDateField(); field.setId(dateFieldMetaData.getId()); field.setName(dateFieldMetaData.getName()); final Date value = proParam.getDate(field.getId()); if (value != null) { final Calendar cal = Calendar.getInstance(); cal.setTime(value); field.setContent(DatatypeConverter.printDate(cal)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } else { for (int i = 1; i <= extent; i++) { final JAXBElement<DateField> fieldElement = new JAXBElement<DateField>( new QName(NS, "Date"), DateField.class, null); final DateField field = OBJECT_FACTORY.createDateField(); field.setId(dateFieldMetaData.getId()); field.setName(dateFieldMetaData.getName()); final Date value = proParam.getDate(field.getId(), i); if (value != null) { final Calendar cal = Calendar.getInstance(); cal.setTime(value); field.setContent(DatatypeConverter.printDate(cal)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } } } else if (fieldMetaData instanceof DateTimeFieldMetaData) { final DateTimeFieldMetaData dateTimeFieldMetaData = (DateTimeFieldMetaData) fieldMetaData; final int extent = dateTimeFieldMetaData.getExtent(); if (extent < 1) { final JAXBElement<DateTimeField> fieldElement = new JAXBElement<DateTimeField>( new QName(NS, "DateTime"), DateTimeField.class, null); final DateTimeField field = OBJECT_FACTORY.createDateTimeField(); field.setId(dateTimeFieldMetaData.getId()); field.setName(dateTimeFieldMetaData.getName()); final GregorianCalendar value = (GregorianCalendar) proParam .getObject(field.getId()); if (value != null) { field.setContent(DatatypeConverter.printDateTime(value)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } else { for (int i = 1; i <= extent; i++) { final JAXBElement<DateTimeField> fieldElement = new JAXBElement<DateTimeField>( new QName(NS, "DateTime"), DateTimeField.class, null); final DateTimeField field = OBJECT_FACTORY.createDateTimeField(); field.setId(dateTimeFieldMetaData.getId()); field.setName(dateTimeFieldMetaData.getName()); final GregorianCalendar value = (GregorianCalendar) proParam .getObject(field.getId(), i); if (value != null) { field.setContent(DatatypeConverter.printDateTime(value)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } } } else if (fieldMetaData instanceof DateTimeTZFieldMetaData) { final DateTimeTZFieldMetaData dateTimeTZFieldMetaData = (DateTimeTZFieldMetaData) fieldMetaData; final int extent = dateTimeTZFieldMetaData.getExtent(); if (extent < 1) { final JAXBElement<DateTimeTZField> fieldElement = new JAXBElement<DateTimeTZField>( new QName(NS, "DateTimeTZ"), DateTimeTZField.class, null); final DateTimeTZField field = OBJECT_FACTORY.createDateTimeTZField(); field.setId(dateTimeTZFieldMetaData.getId()); field.setName(dateTimeTZFieldMetaData.getName()); final GregorianCalendar value = (GregorianCalendar) proParam .getObject(field.getId()); if (value != null) { field.setContent(DatatypeConverter.printDateTime(value)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } else { for (int i = 1; i <= extent; i++) { final JAXBElement<DateTimeTZField> fieldElement = new JAXBElement<DateTimeTZField>( new QName(NS, "DateTimeTZ"), DateTimeTZField.class, null); final DateTimeTZField field = OBJECT_FACTORY .createDateTimeTZField(); field.setId(dateTimeTZFieldMetaData.getId()); field.setName(dateTimeTZFieldMetaData.getName()); final GregorianCalendar value = (GregorianCalendar) proParam .getObject(field.getId(), i); if (value != null) { field.setContent(DatatypeConverter.printDateTime(value)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } } } else if (fieldMetaData instanceof DecFieldMetaData) { final DecFieldMetaData decFieldMetaData = (DecFieldMetaData) fieldMetaData; final int extent = decFieldMetaData.getExtent(); if (extent < 1) { final JAXBElement<DecField> fieldElement = new JAXBElement<DecField>( new QName(NS, "Dec"), DecField.class, null); final DecField field = OBJECT_FACTORY.createDecField(); field.setId(decFieldMetaData.getId()); field.setName(decFieldMetaData.getName()); final BigDecimal value = proParam.getBigDecimal(field.getId()); if (value != null) { field.setContent(DatatypeConverter.printDecimal(value)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } else { for (int i = 1; i <= extent; i++) { final JAXBElement<DecField> fieldElement = new JAXBElement<DecField>( new QName(NS, "Dec"), DecField.class, null); final DecField field = OBJECT_FACTORY.createDecField(); field.setId(decFieldMetaData.getId()); field.setName(decFieldMetaData.getName()); final BigDecimal value = proParam.getBigDecimal(field.getId(), i, 0); if (value != null) { field.setContent(DatatypeConverter.printDecimal(value)); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } } } else if (fieldMetaData instanceof IntFieldMetaData) { final IntFieldMetaData intFieldMetaData = (IntFieldMetaData) fieldMetaData; final int extent = intFieldMetaData.getExtent(); if (extent < 1) { final JAXBElement<IntField> fieldElement = new JAXBElement<IntField>( new QName(NS, "Int"), IntField.class, null); final IntField field = OBJECT_FACTORY.createIntField(); field.setId(intFieldMetaData.getId()); field.setName(intFieldMetaData.getName()); final String value = proParam.getString(field.getId()); if (value != null) { field.setContent( DatatypeConverter.printInt(Integer.parseInt(value))); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } else { for (int i = 1; i <= extent; i++) { final JAXBElement<IntField> fieldElement = new JAXBElement<IntField>( new QName(NS, "Int"), IntField.class, null); final IntField field = OBJECT_FACTORY.createIntField(); field.setId(intFieldMetaData.getId()); field.setName(intFieldMetaData.getName()); final String value = proParam.getString(field.getId(), i); if (value != null) { field.setContent( DatatypeConverter.printInt(Integer.parseInt(value))); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } } } else if (fieldMetaData instanceof LogFieldMetaData) { final LogFieldMetaData logFieldMetaData = (LogFieldMetaData) fieldMetaData; final int extent = logFieldMetaData.getExtent(); if (extent < 1) { final JAXBElement<LogField> fieldElement = new JAXBElement<LogField>( new QName(NS, "Log"), LogField.class, null); final LogField field = OBJECT_FACTORY.createLogField(); field.setId(logFieldMetaData.getId()); field.setName(logFieldMetaData.getName()); final String value = proParam.getString(field.getId()); if (value != null) { field.setContent( DatatypeConverter.printBoolean(Boolean.valueOf(value))); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } else { for (int i = 1; i <= extent; i++) { final JAXBElement<LogField> fieldElement = new JAXBElement<LogField>( new QName(NS, "Log"), LogField.class, null); final LogField field = OBJECT_FACTORY.createLogField(); field.setId(logFieldMetaData.getId()); field.setName(logFieldMetaData.getName()); final String value = proParam.getString(field.getId(), i); if (value != null) { field.setContent( DatatypeConverter.printBoolean(Boolean.valueOf(value))); fieldElement.setValue(field); } else { fieldElement.setNil(true); } row.getFieldElementList().add(fieldElement); } } } } resParam.getRowList().add(row); } resParamElement.setValue(resParam); } else { resParamElement.setNil(true); } res.getParamElementList().add(resParamElement); } } } final Document doc = builder.newDocument(); marshaller.marshal(res, doc); exchange.getOut().setBody(doc); } catch (final RunTime4GLErrorException e) { LOG.error(e.getProcReturnString(), e); throw new OpenEdgeException(e.getProcReturnString(), e); } }
From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java
private void jForwardButtonActionPerformed(java.awt.event.ActionEvent evt) { System.out.println("Loading previous queries for: " + System.getProperty("user")); cellStatus = ""; String searchStr = jSearchStringTextField.getText(); int category = jCategoryComboBox.getSelectedIndex(); int strategy = jContainComboBox.getSelectedIndex(); curCreationDate = previousQueries.get(previousQueries.size() - 1).creationTime(); //////////////////////////////////////////////// SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");//.getDateInstance(); Date date = null;/* w w w .ja v a 2 s.co m*/ try { date = df.parse(this.jStartTimeTextField.getText()); } catch (Exception e) { e.printStackTrace(); } DTOFactory dtoFactory = new DTOFactory(); TimeZone tz = Calendar.getInstance().getTimeZone(); GregorianCalendar cal = new GregorianCalendar(tz); cal.setTime(date); //cal.get(Calendar.ZONE_OFFSET); int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000; //log.info("Timezone: "+tz.getID()+" : "+zt_offset); //if (startTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(cal.get(GregorianCalendar.YEAR), cal.get(GregorianCalendar.MONTH) + 1, cal.get(GregorianCalendar.DAY_OF_MONTH)); xmlC.setTimezone(zt_offset);//0);//-5*60); xmlC.setHour(cal.get(GregorianCalendar.HOUR_OF_DAY)); xmlC.setMinute(cal.get(GregorianCalendar.MINUTE)); xmlC.setSecond(cal.get(GregorianCalendar.SECOND)); constraindateType.setValue(xmlC); //timeConstrain.setDateFrom(constraindateType); //} //////////////////////////////////////////////// String xmlStr = writePagingQueryXML("", category, strategy, false, xmlC);//curCreationDate); // System.out.println(xmlStr); String responseStr = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { responseStr = QueryListNamesClient.sendQueryRequestSOAP(xmlStr); } else { responseStr = QueryListNamesClient.sendFindQueryRequestREST(xmlStr); } if (responseStr.equalsIgnoreCase("CellDown")) { cellStatus = new String("CellDown"); return; //"CellDown"; } try { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseStr); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper().getObjectByClass( bt.getAny(), edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.MasterResponseType.class); for (Condition status : masterResponseType.getStatus().getCondition()) { if (status.getType().equals("ERROR")) cellStatus = new String("CellDown"); } previousQueries = new ArrayList<QueryMasterData>(); for (QueryMasterType queryMasterType : masterResponseType.getQueryMaster()) { QueryMasterData tmpData; tmpData = new QueryMasterData(); XMLGregorianCalendar cldr = queryMasterType.getCreateDate(); tmpData.name( queryMasterType.getName() + " [" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " ]" + " [" + queryMasterType.getUserId() + "]"); tmpData.creationTime(cldr);//.clone()); tmpData.creationTimeStr( addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond()); tmpData.tooltip("A query run by " + queryMasterType.getUserId());// System. // getProperty // ("user")); tmpData.visualAttribute("CA"); tmpData.xmlContent(null); tmpData.id(queryMasterType.getQueryMasterId()); tmpData.userId(queryMasterType.getUserId()); // System.getProperty // ("user")); previousQueries.add(tmpData); } if (previousQueries.size() == 0) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "No results were found.", "Not Found", JOptionPane.INFORMATION_MESSAGE); } }); return; } if (cellStatus.equalsIgnoreCase("")) { reset(200, false, false); } else if (cellStatus.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } return; } catch (Exception e) { e.printStackTrace(); return; } }
From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java
private void jBackwardButtonActionPerformed(java.awt.event.ActionEvent evt) { /*LoginHelper pms = new LoginHelper(); try {/*from ww w .java 2s . c om*/ PasswordType ptype = new PasswordType(); ptype.setIsToken(UserInfoBean.getInstance().getUserPasswordIsToken()); ptype.setTokenMsTimeout(UserInfoBean.getInstance() .getUserPasswordTimeout()); ptype.setValue(UserInfoBean.getInstance().getUserPassword()); String response = pms.getUserInfo(UserInfoBean.getInstance().getUserName(), ptype, UserInfoBean.getInstance().getSelectedProjectUrl(), UserInfoBean.getInstance().getUserDomain(), false, UserInfoBean.getInstance().getProjectId()); } catch(Exception e) { e.printStackTrace(); }*/ System.out.println("Loading previous queries for: " + System.getProperty("user")); cellStatus = ""; String searchStr = jSearchStringTextField.getText(); int category = jCategoryComboBox.getSelectedIndex(); int strategy = jContainComboBox.getSelectedIndex(); curCreationDate = previousQueries.get(0).creationTime(); //////////////////////////////////////////////// SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");//.getDateInstance(); Date date = null; try { date = df.parse(this.jStartTimeTextField.getText()); } catch (Exception e) { e.printStackTrace(); } DTOFactory dtoFactory = new DTOFactory(); TimeZone tz = Calendar.getInstance().getTimeZone(); GregorianCalendar cal = new GregorianCalendar(tz); cal.setTime(date); //cal.get(Calendar.ZONE_OFFSET); int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000; //log.info("Timezone: "+tz.getID()+" : "+zt_offset); //if (startTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(cal.get(GregorianCalendar.YEAR), cal.get(GregorianCalendar.MONTH) + 1, cal.get(GregorianCalendar.DAY_OF_MONTH)); xmlC.setTimezone(zt_offset);//0);//-5*60); xmlC.setHour(cal.get(GregorianCalendar.HOUR_OF_DAY)); xmlC.setMinute(cal.get(GregorianCalendar.MINUTE)); xmlC.setSecond(cal.get(GregorianCalendar.SECOND)); constraindateType.setValue(xmlC); //timeConstrain.setDateFrom(constraindateType); //} //////////////////////////////////////////////// String xmlStr = writePagingQueryXML("", category, strategy, true, xmlC);//curCreationDate); // System.out.println(xmlStr); String responseStr = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { responseStr = QueryListNamesClient.sendQueryRequestSOAP(xmlStr); } else { responseStr = QueryListNamesClient.sendFindQueryRequestREST(xmlStr); } if (responseStr.equalsIgnoreCase("CellDown")) { cellStatus = new String("CellDown"); return; //"CellDown"; } try { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseStr); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper().getObjectByClass( bt.getAny(), edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.MasterResponseType.class); for (Condition status : masterResponseType.getStatus().getCondition()) { if (status.getType().equals("ERROR")) cellStatus = new String("CellDown"); } previousQueries = new ArrayList<QueryMasterData>(); for (QueryMasterType queryMasterType : masterResponseType.getQueryMaster()) { QueryMasterData tmpData; tmpData = new QueryMasterData(); XMLGregorianCalendar cldr = queryMasterType.getCreateDate(); tmpData.name( queryMasterType.getName() + " [" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " ]" + " [" + queryMasterType.getUserId() + "]"); tmpData.creationTime(cldr);//.clone()); tmpData.creationTimeStr( addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond()); tmpData.tooltip("A query run by " + queryMasterType.getUserId());// System. // getProperty // ("user")); tmpData.visualAttribute("CA"); tmpData.xmlContent(null); tmpData.id(queryMasterType.getQueryMasterId()); tmpData.userId(queryMasterType.getUserId()); // System.getProperty // ("user")); previousQueries.add(tmpData); } if (previousQueries.size() == 0) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "No results were found.", "Not Found", JOptionPane.INFORMATION_MESSAGE); } }); return; } if (cellStatus.equalsIgnoreCase("")) { reset(200, false, true); } else if (cellStatus.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } return; } catch (Exception e) { e.printStackTrace(); return; } }