Exemple #1
0
 public void setReporter(NSDictionary dict) {
   plist = dict;
   String systemName = (String) dict.valueForKey("extSystem");
   sys = ExtSystem.extSystemNamed(systemName, ec, true);
   systemName = (String) dict.valueForKey("extBase");
   if (systemName != null) base = sys.getBase(systemName, true);
   if (ec.hasChanges()) ec.saveChanges();
   NSArray list = (NSArray) plist.valueForKey("extData");
   if (list != null && list.count() > 0) {
     extraData = sys.getDataDict(base);
     if (extraData == null) {
       extraData = new NSMutableDictionary();
     } else {
       dataStyle = "display:none;";
       for (int i = 0; i < list.count(); i++) {
         NSDictionary param = (NSDictionary) list.objectAtIndex(i);
         if (!Various.boolForObject(param.valueForKey("required"))) continue;
         String att = (String) param.valueForKey("attribute");
         if (extraData.valueForKey(att) == null) {
           dataStyle = null;
           break;
         }
       }
     }
   }
   list = (NSArray) plist.valueForKey("indexes");
   if (list != null && list.count() > 0) {
     indexes = sys.getIndexes(base);
     if (indexes == null) indexes = new NSMutableDictionary();
   }
   showSections =
       Various.boolForObject(plist.valueForKey("section"))
           && Various.boolForObject(session().valueForKeyPath("sections.hasSections"));
   if (showSections) section = (SchoolSection) session().valueForKeyPath("state.section");
   String checkAccess = (String) plist.valueForKey("checkAccess");
   access =
       (NSKeyValueCoding)
           session()
               .valueForKeyPath(
                   (checkAccess == null)
                       ? "readAccess.FLAGS.Export"
                       : "readAccess.FLAGS." + checkAccess);
 }
Exemple #2
0
  public WOActionResults export() {
    sys.setDataDict(extraData, base);
    sys.setIndexes(indexes, base);
    if (ec.hasChanges()) {
      try {
        ec.saveChanges();
      } catch (Exception e) {
        session().takeValueForKey(e.getMessage(), "message");
        returnPage.ensureAwakeInContext(context());
        return returnPage;
      }
    }
    NSMutableDictionary reportDict = new NSMutableDictionary();
    reportDict.takeValueForKey(plist, "reporter");
    reportDict.takeValueForKey(section, "section");
    reportDict.takeValueForKey(ec, "ec");
    reportDict.takeValueForKey(indexes, "indexes");
    reportDict.takeValueForKey("ImportExport", "reportDir");
    reportDict.takeValueForKey(session().valueForKey("today"), "today");

    NSMutableDictionary info =
        new NSMutableDictionary(
            MyUtility.presentEduYear((Integer) session().valueForKey("eduYear")), "eduYear");
    info.takeValueForKey(extraData, "extraData");
    NSArray indList = (NSArray) plist.valueForKey("indexes");
    if (indList != null && indList.count() > 0) {
      for (int i = 0; i < indList.count(); i++) {
        NSDictionary ind = (NSDictionary) indList.objectAtIndex(i);
        if (Various.boolForObject(ind.valueForKey("inOptions"))) {
          String indName = (String) ind.valueForKey("name");
          info.takeValueForKey(indexes.valueForKey(indName), indName);
        }
      }
    }
    reportDict.takeValueForKey(info, "info");
    if (returnPage instanceof ImportExport) returnPage.takeValueForKey(plist, "reporter");
    Progress progress = (Progress) pageWithName("Progress");
    progress.returnPage = returnPage;
    progress.resultPath = (String) plist.valueForKey("resultPath");
    if (progress.resultPath == null) progress.resultPath = "result";
    progress.title = (String) plist.valueForKey("title");
    progress.state = XMLGenerator.backgroundGenerate(reportDict);
    return progress.refresh();
    /*
    byte[] result = null;
    try {
    	result = XMLGenerator.generate(session(), (NSMutableDictionary)reportDict);
    } catch (Exception e) {
    	result = WOLogFormatter.formatTrowable(e).getBytes();
    }
    WOResponse response = application().createResponseInContext(context());
    response.setContent(result);
    String contentType = (String)plist.valueForKey("ContentType");
    if(contentType == null)
    	contentType = "application/octet-stream";
    response.setHeader(contentType,"Content-Type");
    StringBuilder buf = new StringBuilder("attachment; filename=\"");
    buf.append("filename");
    contentType = (String)plist.valueForKey("filext");
    if(contentType != null) {
    	if(contentType.charAt(0) != '.')
    		buf.append('.');
    	buf.append(contentType);
    }
    buf.append('"');
    response.setHeader(buf.toString(),"Content-Disposition");
    return response; */
  }