Пример #1
0
 private String localValue() {
   if (item1 == null || item1 instanceof String) {
     return (String) item1;
   } else {
     String path = (String) indexItem.valueForKeyPath("local.valuePath");
     if (path == null) {
       return MyUtility.getID((EOEnterpriseObject) item1);
     } else {
       return NSKeyValueCodingAdditions.Utility.valueForKeyPath(item1, path).toString();
     }
   }
 }
Пример #2
0
 public static WOActionResults exportJournalZPU(
     NSArray journal, WOContext context, String filename) {
   WOSession ses = context.session();
   if (journal == null || journal.count() == 0) {
     WOResponse response = WOApplication.application().createResponseInContext(context);
     response.appendContentString(
         (String) ses.valueForKeyPath("strings.RujelCurriculum_Curriculum.Tabel.noData"));
     response.setHeader("application/octet-stream", "Content-Type");
     response.setHeader("attachment; filename=\"noData.txt\"", "Content-Disposition");
     return response;
   }
   Export export = new ExportCSV(context, filename);
   export.beginRow();
   export.addValue(ses.valueForKeyPath("strings.Reusables_Strings.dataTypes.Date"));
   export.addValue(ses.valueForKeyPath("strings.RujelCurriculum_Curriculum.OrigTeacher"));
   export.addValue(ses.valueForKeyPath("strings.RujelInterfaces_Names.EduCycle.subject"));
   export.addValue(ses.valueForKeyPath("strings.RujelInterfaces_Names.EduGroup.this"));
   export.addValue(ses.valueForKeyPath("strings.RujelCurriculum_Curriculum.Reason.Reason"));
   export.addValue(ses.valueForKeyPath("strings.RujelCurriculum_Curriculum.Reason.verification"));
   export.addValue(
       ses.valueForKeyPath("strings.RujelCurriculum_Curriculum.Substitute.Substitutor"));
   export.addValue(ses.valueForKeyPath("strings.RujelInterfaces_Names.EduCycle.subject"));
   export.addValue(ses.valueForKeyPath("strings.RujelCurriculum_Curriculum.Substitute.factor"));
   Enumeration enu = journal.objectEnumerator();
   StringBuilder buf = new StringBuilder();
   while (enu.hasMoreElements()) {
     NSDictionary dict = (NSDictionary) enu.nextElement();
     export.beginRow();
     export.addValue(MyUtility.dateFormat().format(dict.valueForKey("date")));
     EduCourse course = (EduCourse) dict.valueForKey("minusCourse");
     if (course != null) {
       Teacher teacher = (Teacher) dict.valueForKey("minusTeacher");
       if (teacher != null) export.addValue(Person.Utility.fullName(teacher, true, 2, 1, 1));
       else export.addValue(ses.valueForKeyPath("strings.RujelBase_Base.vacant"));
       if (course.comment() == null) {
         export.addValue(course.cycle().subject());
       } else {
         buf.delete(0, buf.length());
         buf.append(course.cycle().subject());
         buf.append(' ').append('(').append(course.comment()).append(')');
         export.addValue(buf.toString());
       }
     } else {
       export.addValue(null);
       export.addValue(null);
     }
     if (dict.valueForKey("eduGroup") != null)
       export.addValue(dict.valueForKeyPath("eduGroup.name"));
     else export.addValue(dict.valueForKey("grade"));
     export.addValue(dict.valueForKeyPath("reason.title"));
     export.addValue(dict.valueForKeyPath("reason.verification"));
     course = (EduCourse) dict.valueForKey("plusCourse");
     if (course != null) {
       Teacher teacher = (Teacher) dict.valueForKey("plusTeacher");
       export.addValue(Person.Utility.fullName(teacher, true, 2, 1, 1));
       if (course.comment() == null) {
         export.addValue(course.cycle().subject());
       } else {
         buf.delete(0, buf.length());
         buf.append(course.cycle().subject());
         buf.append(' ').append('(').append(course.comment()).append(')');
         export.addValue(buf.toString());
       }
     } else {
       export.addValue(null);
       export.addValue(null);
     }
     export.addValue(dict.valueForKey("value"));
   }
   return export;
 }
Пример #3
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; */
  }