Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014 Philip Helger (www.helger.com) philip[at]helger[dot]com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package com.helger.appbasics.longrun;
 
 
 
This class contains the data for a single long running job.

Author(s):
Philip Helger
 
 public final class LongRunningJobData implements IHasID <String>
 {
   private final String m_sID;
 
   // Initial job data
   private final DateTime m_aStartDateTime;
   private final String m_sStartingUserID;
 
   // Data set on job end:
   private DateTime m_aEndDateTime;
   private ESuccess m_eExecSuccess;
 
   public LongRunningJobData (@Nonnull @Nonempty final String sJobID,
                              @Nonnull final ISimpleMultiLingualText aJobDescription,
                              @Nullable final String sStartingUserID)
   {
      = ValueEnforcer.notEmpty (sJobID"JobID");
      = ValueEnforcer.notNull (aJobDescription"JobDescription");
      = PDTFactory.getCurrentDateTime ();
      = sStartingUserID;
   }
 
   LongRunningJobData (@Nonnull @Nonempty final String sID,
                       @Nonnull final DateTime aStartDateTime,
                       @Nonnull final DateTime aEndDateTime,
                       @Nonnull final ESuccess eExecSuccess,
                       @Nullable final String sStartingUserID,
                       @Nonnull final IReadonlyMultiLingualText aJobDescription,
                       @Nonnull final LongRunningJobResult aResult)
   {
      = ValueEnforcer.notEmpty (sID"ID");
      = ValueEnforcer.notNull (aStartDateTime"StartDateTime");
      = ValueEnforcer.notNull (aEndDateTime"EndDateTime");
      = ValueEnforcer.notNull (eExecSuccess"ExecSuccess");
      = sStartingUserID;
      = ValueEnforcer.notNull (aJobDescription"JobDescription");
      = ValueEnforcer.notNull (aResult"Result");
   }
 
   @Nonnull
   @Nonempty
   public String getID ()
   {
     return ;
   }

  

Returns:
The description of the underlying job. Never null.
 
   @Nonnull
   {
     return ;
   }

  

Returns:
The date time when the job was started. Never null.
  public DateTime getStartDateTime ()
  {
    return ;
  }

  

Returns:
The user who started the job. May be null.
  public String getStartingUserID ()
  {
    return ;
  }
  void onJobEnd (@Nonnull final ESuccess eExecSucess, @Nonnull final LongRunningJobResult aResult)
  {
    if (eExecSucess == null)
      throw new NullPointerException ("execSuccess");
    if (aResult == null)
      throw new NullPointerException ("result");
    if (isEnded ())
      throw new IllegalStateException ("Job was already ended");
    // Save the date
     = PDTFactory.getCurrentDateTime ();
     = eExecSucess;
    // Build the main results
     = aResult;
    if ( == null)
      throw new IllegalStateException ("Failed to create job results object!");
  }

  

Returns:
true if this job was already ended
  public boolean isEnded ()
  {
    return  != null;
  }

  

Returns:
The date and time when the job execution finished
  public DateTime getEndDateTime ()
  {
    return ;
  }

  

Returns:
The execution duration
  public Duration getDuration ()
  {
    if (!isEnded ())
      throw new IllegalStateException ("Job is still running!");
    return new Duration (getEndDateTime ());
  }

  

Returns:
The technical success indicator, whether the scheduled job ran without an exception.
  {
    return ;
  }

  

Returns:
The semantic result of the execution.
  {
    return ;
  }
  public String toString ()
  {
    return new ToStringGenerator (this).append ("ID")
                                       .append ("jobDescription")
                                       .append ("startDateTime")
                                       .append ("startingUserID")
                                       .append ("endDateTime")
                                       .append ("execSucces")
                                       .append ("result")
                                       .toString ();
  }
New to GrepCode? Check out our FAQ X