📄 reportmanagerejb.java
字号:
new_pattern += " " + old_pattern_time; } else { old_pattern = old_pattern_date; } try { newDate = DateHelper.formatDate(DateHelper.parseDate(oldDate, old_pattern), new_pattern); } catch (ParseException e) { } if(newDate != null) { ressField.setResFieldValue(newDate); DEBUG(" Date was re-formatted to: " + newDate); } } } /** * Tells us is entity dataset to be included to report. * Returns true, if any error occured. * * @param entityMap cached per each method request entities. Entity has the type {@link com.queplix.core.jxb.entity.Entity} * @param entityName entity name. Entity has the type {@link com.queplix.core.jxb.entity.Entity} * @param datasetName dataset name. Should be represented in entity * @return is entity dataset to be included to report */ private boolean isEntityDataSetToBeIncludedToReport(Map entityMap, String entityName, String datasetName) { boolean ret = true;//due to the fact, that we inject new functionality, by default if some problem // is occured and we have unknown field, just include it to report Entity entityView; if(datasetName != null && entityName != null) { entityView = retrieveEntity(entityMap, entityName); Dataset dataset = getDatasetFromEntity(entityView, datasetName); if(dataset != null) { ret = dataset.getIncludeToReport().booleanValue(); } } return ret; } /** * Retrieves entity by it's name from the cache, or if it's not there get it from EntityViewConfigManager ejb. * Could be null * * @param entityMap cache map * @param entityName name of the entity * @return entity. */ private Entity retrieveEntity(Map entityMap, String entityName) { Entity entityView; if(entityMap.containsKey(entityName)) { entityView = (Entity) entityMap.get(entityName); } else { try { EntityViewConfigManagerLocal configManager = (EntityViewConfigManagerLocal) getLocalObject(JNDINames.EntityViewConfigManager, EntityViewConfigManagerLocalHome.class); entityView = configManager.getEntityViewConfig(entityName); entityMap.put(entityName, entityView); } catch (Exception e) { //in case of we haven't link to ejb, or entity is null. ERROR("Report manager EJB should has link to EntityViewConfigManager EJB, and entity \"" + entityName + "\" should exists"); entityView = null; } } return entityView; } /** * Tells us is entity field to be included to report. * Returns true, if any error occured. * * @param entityMap cached per each method request entities. Entity has the type {@link com.queplix.core.jxb.entity.Entity} * @param entityName entity name. Entity has the type {@link com.queplix.core.jxb.entity.Entity} * @param fieldName field name. Should be represented in entity * @return is entity field to be included to report */ private boolean isEntityFieldToBeIncludedToReport(Map entityMap, String entityName, String fieldName) { boolean ret = true;//due to the fact, that we inject new functionality, by default if some problem // is occured or we have unknown field, just include it to report Entity entityView; if(fieldName != null && entityName != null) { entityView = retrieveEntity(entityMap, entityName); Efield entityField = getFieldFromEntity(entityView, fieldName); if(entityField != null) { ret = entityField.getIncludeToReport().booleanValue(); } } return ret; } /** * Retrieves field from the entity. Compare them by the fields names. * Returns null if any error occured. * * @param entityView entity from which field should be found. * @param fieldName name of the field. * @return field. */ private Efield getFieldFromEntity(Entity entityView, String fieldName) { Efield ret = null; if(fieldName != null && entityView != null) { Efield[] fields = entityView.getEfield(); for(int i = 0; i < fields.length; i++) { String currentFieldName = fields[i].getName(); if(fieldName.equalsIgnoreCase(currentFieldName)) { ret = fields[i]; break; } } } return ret; } /** * Retrieves dataset from the entity. Compare them by the dataset names. * Returns null if any error occured. * * @param entityView entity from which field should be found. * @param datasetName name of the dataset. * @return dataset. */ private Dataset getDatasetFromEntity(Entity entityView, String datasetName) { Dataset ret = null; if(datasetName != null && entityView != null) { Dataset[] datasets = entityView.getDataset(); for(int i = 0; i < datasets.length; i++) { String currentDatasetName = datasets[i].getName(); if(datasetName.equalsIgnoreCase(currentDatasetName)) { ret = datasets[i]; break; } } } return ret; } // // Gets the temporary zip file . // private File getZipFile() throws IOException { String path = SysPropertyManager.getProperty("REPORT_ZIP_DIR"); String name = ReportHelper.REPORT_FILE_NAME + "_" + System.currentTimeMillis() + ZipHelper.ZIP_EXT; // Check parent directory. File dir = new File(path); if(!dir.exists() && !dir.mkdirs()) { throw new FileNotFoundException("Can't create data directory '" + path + "'."); } if(!dir.isDirectory()) { throw new IOException("Not a directory: '" + path + "'."); } // Ok. return new File(path, name); } // // Makes a report HTML view by XSLT. // private String makeHTML(LogonSession ls, Report report, int iterId, boolean isFirst, boolean isLast, Form form, Ress ress, String transletClassName) { return makeHTML(ls, report, iterId, isFirst, isLast, form, ress, transletClassName, null); } private String makeHTML(LogonSession ls, Report report, int iterId, boolean isFirst, boolean isLast, Form form, Ress ress, String transletClassName, Map transletParams) { // Construct Reportiter object. Reportiter reportIteration = new Reportiter(); reportIteration.setIterId(new Long(iterId)); reportIteration.setIsFirst(new Boolean(isFirst)); reportIteration.setIsLast(new Boolean(isLast)); if(form != null) { reportIteration.setIterTitle(form.getCaption()); } report.setReportiter(reportIteration); // Set report data and serialize Report object. reportIteration.setRess(ress); char[] data = XMLHelper.writeObject(report); // Do XSLT. StreamSource source = new StreamSource(new CharArrayReader(data)); CharArrayWriter out = new CharArrayWriter(); try { transletWrapper.transform(source, new StreamResult(out), transletClassName, transletParams); } catch (GenericSystemException ex) { ERROR("Cannot transform source: \n" + String.valueOf(data) + "\n\n", ex); throw ex; } // Ok. return out.toString(); } // // Makes the e-mail message and sends it. // private void sendByMail(LogonSession ls, String from, String to, String cc, String subject, String body, Attachment[] attachments) throws MessagingException { // Prepare the e-mail message: MailAddress[] toAddr = MailAddress.parse(to); MailMessage message = new MailMessage(toAddr, subject, body); if(!StringHelper.isEmpty(cc)) { MailAddress[] ccAddr = MailAddress.parse(cc); message.setCc(ccAddr); } if(!StringHelper.isEmpty(from)) { MailAddress fromAddr = new MailAddress(from); message.setFrom(fromAddr); } // Send the message. MailManagerLocal mailManager = (MailManagerLocal) getLocalObject(JNDINames.MailManager, MailManagerLocalHome.class); mailManager.sendMessage(ls, message, null, attachments); } // // Gets Form object // private Form getForm(LogonSession ls, Reqs reqs) { ReqEntity reqEntity = reqs.getReq().getReqEntity(); String formId = (reqEntity == null) ? null:reqEntity.getFormid(); if(formId == null) { return null; } FocusConfigManagerLocal local = (FocusConfigManagerLocal) getLocalObject(JNDINames.FocusConfigManager, FocusConfigManagerLocalHome.class); return local.getLocalizedForm(ls.getUser().getLangID(), formId); } private static class ReportCallbackAdapter implements ReportCallbackHnd { public void call(ReportCallbackHndEvent ev) throws EQLException { //do nothing, don't need get status here } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -