示例#1
0
 /**
  * Method for cleaning the execution.
  *
  * @param task the task of execution.
  * @throws java.lang.Exception if there is any problem with cleaning.
  */
 public static void clean(elv.task.Task task) throws java.lang.Exception {
   // Clean execution.
   task.clean();
   // Set and store properties.
   elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties())
       .setValue(new elv.util.State(elv.util.State.DEFINED));
   elv.util.Property.get(elv.task.Task.MODIFIED_NAME, task.getProperties())
       .setValue(new java.util.Date());
   elv.util.Property.get(elv.task.Task.SCHEDULED_NAME, task.getProperties()).setValue(null);
   elv.util.Property.get(elv.task.Task.STARTED_NAME, task.getProperties()).setValue(null);
   elv.util.Property.get(elv.task.Task.STOPPED_NAME, task.getProperties()).setValue(null);
   task.storeProperties();
 }
示例#2
0
  /** Implemented method from interface <CODE>java.util.TimerTask</CODE>. */
  public void run() {
    try {
      // Set and store properties.
      elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties())
          .setValue(new elv.util.State(elv.util.State.EXECUTED));
      elv.util.Property.get(elv.task.Task.STARTED_NAME, task.getProperties())
          .setValue(new java.util.Date());
      elv.util.Property.get(elv.task.Task.STOPPED_NAME, task.getProperties()).setValue(null);
      task.storeProperties();

      // Execute.
      for (elv.task.executables.Executable iteratorExecutable : task.getExecutables()) {
        iteratorExecutable.execute(this);
        if (!isExecuted) {
          break;
        }
      }
      timer.cancel();

      // Set and store properties.
      if (isExecuted()) {
        elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties())
            .setValue(new elv.util.State(elv.util.State.DONE));
      } else {
        elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties())
            .setValue(new elv.util.State(elv.util.State.STOPPED));
      }
      elv.util.Property.get(elv.task.Task.STOPPED_NAME, task.getProperties())
          .setValue(new java.util.Date());
      task.storeProperties();

    } catch (java.lang.Exception exc) {
      elv.util.Error.setExecutionError(task, exc);
      try {
        elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties())
            .setValue(new elv.util.State(elv.util.State.ERROR));
        elv.util.Property.get(elv.task.Task.STOPPED_NAME, task.getProperties())
            .setValue(new java.util.Date());
        task.storeProperties();
      } catch (java.lang.Exception ex) {
        elv.util.Error.logServerError(ex);
      }
    }
    isExecuted = false;
  }
示例#3
0
 /** Implemented method from <CODE>elv.util.Saveable</CODE>. */
 public void save() {
   if (isChanged()) {
     try {
       elv.util.client.ClientStub.storeParameters(
           task.getPropertyFolderPath() + elv.util.Util.getFS() + parameterType.getFile(),
           diagnosises);
       if (task != null) {
         elv.util.Property.get(elv.task.Task.MODIFIED_NAME, task.getProperties())
             .setValue(new java.util.Date());
         java.lang.String pathName =
             task.getPropertyFolderPath() + elv.util.Util.getFS() + task.getPropertyFile();
         elv.util.client.ClientStub.storeProperties(pathName, task.getProperties());
         // Fire property change for reload the task properties.
         task.getChangeSupport().firePropertyChange(elv.task.Task.MODIFIED_NAME, null, state);
       }
       setChanged(false);
     } catch (java.lang.Exception exc) {
       elv.util.Error.showErrorMessage(this, exc);
     }
   }
 }
示例#4
0
  /**
   * Constructor.
   *
   * @param diagnosises a vector of diagnosises.
   * @param parameterType the type of diagnosises.
   * @param cloneableTask the task with the cloneable diagnosises.
   */
  public DiagnosisesPanel(
      elv.task.Task task,
      elv.util.parameters.Diagnosis parameterType,
      elv.task.Task cloneableTask) {
    this.task = task;
    this.parameterType = parameterType;
    try {
      state =
          (elv.util.State)
              elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties()).getValue();
      isEnabled =
          (!(task.getContainer() instanceof elv.task.Archive)
              && (state.equals(new elv.util.State(elv.util.State.UNDEFINED))
                  || state.equals(new elv.util.State(elv.util.State.DEFINED))
                  || state.equals(new elv.util.State(elv.util.State.SCHEDULED))));
      if (state.equals(new elv.util.State(elv.util.State.UNDEFINED))) {
        diagnosises = new java.util.Vector<elv.util.parameters.Diagnosis>();
        if (cloneableTask != null) {
          elv.util.State cloneState =
              (elv.util.State)
                  elv.util.Property.get(elv.task.Task.STATE_NAME, cloneableTask.getProperties())
                      .getValue();
          if (!cloneState.equals(new elv.util.State(elv.util.State.UNDEFINED))) {
            if (cloneableTask.getContainer() instanceof elv.task.Archive) {
              java.lang.String name =
                  cloneableTask.getName()
                      + elv.util.Util.ZIP_SEPARATOR
                      + cloneableTask.PROPERTY_FOLDER
                      + elv.util.Util.ZIP_SEPARATOR
                      + parameterType.getFile();
              diagnosises =
                  elv.util.client.ClientStub.loadParameters(
                      cloneableTask.getContainer().getFolderPath(), name, parameterType);
            } else {
              diagnosises =
                  elv.util.client.ClientStub.loadParameters(
                      cloneableTask.getPropertyFolderPath(),
                      parameterType.getFile(),
                      parameterType);
            }
          }
        }
      } else {
        if (task.getContainer() instanceof elv.task.Archive) {
          java.lang.String name =
              task.getName()
                  + elv.util.Util.ZIP_SEPARATOR
                  + task.PROPERTY_FOLDER
                  + elv.util.Util.ZIP_SEPARATOR
                  + parameterType.getFile();
          diagnosises =
              elv.util.client.ClientStub.loadParameters(
                  task.getContainer().getFolderPath(), name, parameterType);
        } else {
          diagnosises =
              elv.util.client.ClientStub.loadParameters(
                  task.getPropertyFolderPath(), parameterType.getFile(), parameterType);
        }
      }
      // Set state change support.
      task.getChangeSupport()
          .addPropertyChangeListener(
              elv.util.State.TITLE,
              new java.beans.PropertyChangeListener() {
                public void propertyChange(java.beans.PropertyChangeEvent evt) {
                  stateChange(evt);
                }
              });

      initComponents();
      setEnabled(isEnabled);
    } catch (java.lang.Exception exc) {
      elv.util.Error.showErrorMessage(this, exc);
    }
  }
示例#5
0
  /**
   * Method for loading all parameters of this execution.
   *
   * @throws java.lang.Exception if there is any problem with loading.
   */
  private void loadParameters() throws java.lang.Exception {
    // Initialize parameters.
    ageIntervals = new java.util.Vector<elv.util.parameters.AgeInterval>();
    yearIntervals = new java.util.Vector<elv.util.parameters.YearInterval>();
    baseSettlements = new java.util.Vector<elv.util.parameters.BaseSettlement>();
    benchmarkSettlements = new java.util.Vector<elv.util.parameters.BenchmarkSettlement>();
    districts = new java.util.Vector<elv.util.parameters.District>();
    diseases = new java.util.Vector<elv.util.parameters.DiseaseDiagnosis>();
    mortalities = new java.util.Vector<elv.util.parameters.MortalityDiagnosis>();
    morbidities = new java.util.Vector<elv.util.parameters.MorbidityDiagnosis>();
    addmissions = new java.util.Vector<elv.util.parameters.AddmissionDiagnosis>();
    morfologies = new java.util.Vector<elv.util.parameters.MorfologyDiagnosis>();
    dismissals = new java.util.Vector<elv.util.parameters.DismissalDiagnosis>();
    spots = new java.util.Vector<elv.util.parameters.Spot>();

    // Load parameters.
    for (elv.util.parameters.Parameter parameterType : task.getParameterTypes()) {
      java.lang.String containerPath = task.getPropertyFolderPath();
      java.lang.String name = parameterType.getFile();
      if (parameterType instanceof elv.util.parameters.YearInterval) {
        yearIntervals =
            elv.util.parameters.Parameter.load(
                containerPath, name, (elv.util.parameters.YearInterval) parameterType);
        if (yearIntervals.isEmpty()) {
          elv.util.parameters.YearInterval yearInterval = parameterType.getDefault();
          yearIntervals.add(yearInterval);
        }
      } else if (parameterType instanceof elv.util.parameters.AgeInterval) {
        ageIntervals =
            elv.util.parameters.Parameter.load(
                containerPath, name, (elv.util.parameters.AgeInterval) parameterType);
      } else if (parameterType instanceof elv.util.parameters.BaseSettlement) {
        baseSettlements =
            elv.util.parameters.Parameter.load(
                containerPath, name, (elv.util.parameters.BaseSettlement) parameterType);
        name = new elv.util.parameters.District().getFile();
        districts =
            elv.util.parameters.District.load(
                containerPath, name, new elv.util.parameters.District());
      } else if (parameterType instanceof elv.util.parameters.BenchmarkSettlement) {
        benchmarkSettlements =
            elv.util.parameters.Parameter.load(
                containerPath, name, (elv.util.parameters.BenchmarkSettlement) parameterType);
      } else if (parameterType instanceof elv.util.parameters.DiseaseDiagnosis) {
        diseases =
            elv.util.parameters.AgeInterval.load(
                containerPath, name, (elv.util.parameters.DiseaseDiagnosis) parameterType);
      } else if (parameterType instanceof elv.util.parameters.MortalityDiagnosis) {
        mortalities =
            elv.util.parameters.AgeInterval.load(
                containerPath, name, (elv.util.parameters.MortalityDiagnosis) parameterType);
      } else if (parameterType instanceof elv.util.parameters.MorbidityDiagnosis) {
        morbidities =
            elv.util.parameters.AgeInterval.load(
                containerPath, name, (elv.util.parameters.MorbidityDiagnosis) parameterType);
      } else if (parameterType instanceof elv.util.parameters.AddmissionDiagnosis) {
        addmissions =
            elv.util.parameters.AgeInterval.load(
                containerPath, name, (elv.util.parameters.AddmissionDiagnosis) parameterType);
      } else if (parameterType instanceof elv.util.parameters.AddmissionDiagnosis) {
        addmissions =
            elv.util.parameters.AgeInterval.load(
                containerPath, name, (elv.util.parameters.AddmissionDiagnosis) parameterType);
      } else if (parameterType instanceof elv.util.parameters.MorfologyDiagnosis) {
        morfologies =
            elv.util.parameters.AgeInterval.load(
                containerPath, name, (elv.util.parameters.MorfologyDiagnosis) parameterType);
      } else if (parameterType instanceof elv.util.parameters.DismissalDiagnosis) {
        dismissals =
            elv.util.parameters.AgeInterval.load(
                containerPath, name, (elv.util.parameters.DismissalDiagnosis) parameterType);
      }
    }
    allSettlements = new java.util.Vector<elv.util.parameters.Settlement>();
    for (elv.util.parameters.Settlement iteratorSettlement : baseSettlements) {
      allSettlements.add(iteratorSettlement);
    }
    for (elv.util.parameters.Settlement iteratorSettlement : benchmarkSettlements) {
      allSettlements.add(iteratorSettlement);
    }
    // Load ecxecutable properties and
    // define the age-intervals, the year-intervals and the years.
    years = new java.util.Vector<java.lang.Integer>();
    boolean yearFound = false;
    boolean benchmarkYearFound = false;
    elv.task.executables.StandardPreparation standardPreparation = null;
    for (elv.task.executables.Executable iteratorExecutable : task.getExecutables()) {
      iteratorExecutable.setProperties(
          elv.util.Property.load(
              task.getPropertyFolderPath(), iteratorExecutable.getPropertyFile()));
      if (iteratorExecutable instanceof elv.task.executables.StandardPreparation) {
        standardPreparation = (elv.task.executables.StandardPreparation) iteratorExecutable;
        break;
      }
    }
    benchmarkYear = 0;
    if (standardPreparation != null) {
      // Get benchmark year.
      benchmarkYear =
          (java.lang.Integer)
              elv.util.Property.get(
                      elv.task.executables.Preparation.BENCHMARK_YEAR_NAME,
                      standardPreparation.getProperties())
                  .getValue();
    }
    for (elv.util.parameters.Interval iteratorYearInterval : yearIntervals) {
      for (int i = iteratorYearInterval.getFromValue();
          i <= iteratorYearInterval.getToValue();
          i++) {
        int year = i;
        if (year == benchmarkYear) {
          benchmarkYearFound = true;
        }
        for (int iteratorYear : years) {
          if (year == iteratorYear) {
            yearFound = true;
            break;
          }
        }
        if (!yearFound) {
          years.add(year);
        }
      }
    }
    if (benchmarkYear != 0 && !benchmarkYearFound) {
      years.add(benchmarkYear);
    }
  }