Пример #1
0
 @Secured("ROLE_ADMIN")
 public DataImportStateProxy startSummaryCreation(boolean overwriteAll) throws DataImportExeption {
   if (dataImportProcess == null || !dataImportProcess.isRunning()) {
     SessionState sessionState = sessionManager.getSessionState();
     File userImportFolder = new File(importDirectory, sessionState.getSessionId());
     packagedFile = new File(userImportFolder, FILE_NAME);
     List<User> usersList = userManager.loadAll();
     HashMap<String, User> users = new HashMap<String, User>();
     for (User user : usersList) {
       users.put(user.getName(), user);
     }
     dataImportProcess =
         new DataImportProcess(
             surveyManager, recordManager, recordDao, users, packagedFile, overwriteAll);
     dataImportProcess.prepareToStartSummaryCreation();
     ExecutorServiceUtil.executeInCachedPool(dataImportProcess);
   }
   DataImportState state = dataImportProcess.getState();
   DataImportStateProxy proxy = new DataImportStateProxy(state);
   return proxy;
 }
Пример #2
0
  public void write(CollectRecord record, Writer out) throws IOException, XmlPullParserException {
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    XmlSerializer serializer = factory.newSerializer();
    serializer.setFeature(INDENT_FEATURE, true);
    serializer.setOutput(out);
    // do not use UTF-8 encoding: unicode text will be escaped by the serializer instead
    // serializer.startDocument("UTF-8", true);
    serializer.startDocument(null, true);

    Entity rootEntity = record.getRootEntity();
    String rootEntityName = rootEntity.getName();
    serializer.startTag(null, rootEntityName);

    ModelVersion version = record.getVersion();
    if (version != null) {
      serializer.attribute(null, RECORD_VERSION_ATTRIBUTE, version.getName());
    }
    serializer.attribute(
        null, RECORD_STEP_ATTRIBUTE, Integer.toString(record.getStep().getStepNumber()));
    if (record.getState() != null) {
      serializer.attribute(null, STATE_ATTRIBUTE, record.getState().getCode());
    }
    User createdBy = record.getCreatedBy();
    if (createdBy != null) {
      serializer.attribute(null, RECORD_CREATED_BY_ATTRIBUTE, createdBy.getName());
    }
    User modifiedBy = record.getModifiedBy();
    if (modifiedBy != null) {
      serializer.attribute(null, RECORD_MODIFIED_BY_ATTRIBUTE, modifiedBy.getName());
    }
    addDateAttribute(serializer, RECORD_CREATED_ATTRIBUTE, record.getCreationDate());
    addDateAttribute(serializer, RECORD_MODIFIED_ATTRIBUTE, record.getModifiedDate());

    writeChildren(serializer, rootEntity);
    serializer.endTag(null, rootEntityName);
    serializer.endDocument();
    serializer.flush();
  }