Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.common.headless.transform
Class TransformationWorkspace

java.lang.Object
  extended by eu.esdihumboldt.hale.common.headless.transform.TransformationWorkspace

public class TransformationWorkspace
extends Object

A transformation workspace based on WorkspaceService and EnvironmentService.

Author:
Simon Templer

Constructor Summary
  TransformationWorkspace()
          Create a new transformation workspace with a lease duration of one day.
  TransformationWorkspace(org.joda.time.ReadableDuration leaseDuration)
          Create a new transformation workspace with a custom lease duration.
  TransformationWorkspace(String workspaceId)
          Create a representation of an existing transformation workspace.
protected TransformationWorkspace(String workspaceId, org.joda.time.ReadableDuration leaseDuration)
          Create a new workspace or use an existing one.
 
Method Summary
 void delete()
          Delete the workspace
 String getId()
           
 File getReportFile()
          Get the report file.
 File getSourceFolder()
          Get the source folder.
 File getTargetFolder()
          Get the target folder.
 File getWorkspace()
           
 boolean isTransformationFinished()
          Determines if a previously with transform(String, List, IOConfiguration) started transformation process is finished.
 boolean isTransformationSuccessful()
          Determines if a previously with transform(String, List, IOConfiguration) started transformation process was complete successfully.
protected  void setTransformationSuccess(boolean success)
          Set if the transformation was successfully completed.
 com.google.common.util.concurrent.ListenableFuture<Boolean> transform(String envId, List<InstanceReader> sources, IOConfiguration target)
          Transform the instances provided through the given instance readers and store the result in the getTargetFolder().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformationWorkspace

public TransformationWorkspace()
Create a new transformation workspace with a lease duration of one day.

Throws:
IllegalStateException - if the WorkspaceService is not available

TransformationWorkspace

public TransformationWorkspace(org.joda.time.ReadableDuration leaseDuration)
Create a new transformation workspace with a custom lease duration.

Parameters:
leaseDuration - the lease duration of the workspace
Throws:
IllegalStateException - if the WorkspaceService is not available

TransformationWorkspace

public TransformationWorkspace(String workspaceId)
Create a representation of an existing transformation workspace.

Parameters:
workspaceId - the workspace identifier
Throws:
IllegalStateException - if the WorkspaceService is not available or the workspace with the given identifier does not exist

TransformationWorkspace

protected TransformationWorkspace(String workspaceId,
                                  org.joda.time.ReadableDuration leaseDuration)
Create a new workspace or use an existing one.

Parameters:
workspaceId - the workspace identifier if this object should represent an existing workspace, may be null if leaseDuration is set.
leaseDuration - the lease duration of a new workspace to create, may be null if workspaceId is set
Throws:
IllegalStateException - if the WorkspaceService is not available or the workspace with the given identifier does not exist
Method Detail

transform

public com.google.common.util.concurrent.ListenableFuture<Boolean> transform(String envId,
                                                                             List<InstanceReader> sources,
                                                                             IOConfiguration target)
                                                                      throws Exception
Transform the instances provided through the given instance readers and store the result in the getTargetFolder().

Parameters:
envId - the environment ID
sources - the instance readers
target - the configuration of the target instance writer
Returns:
the future representing the successful completion of the transformation (note that a successful completion doesn't necessary mean there weren't any internal transformation errors)
Throws:
Exception - if launching the transformation fails

isTransformationFinished

public boolean isTransformationFinished()
Determines if a previously with transform(String, List, IOConfiguration) started transformation process is finished. Regardless of the success or failure.

Returns:
true if the transformation is finished, false if the transformation is still running, no transformation was started or the workspace no longer exists

isTransformationSuccessful

public boolean isTransformationSuccessful()
                                   throws IllegalStateException
Determines if a previously with transform(String, List, IOConfiguration) started transformation process was complete successfully. Note that a successful completion doesn't necessary mean there weren't any internal transformation errors. The getReportFile() holds more detailed information.

This method may only be called of the transformation is finished, otherwise an IllegalStateException will be thrown.

Returns:
if the transformation was completed successfully
Throws:
IllegalStateException - if the transformation is not finished
See Also:
isTransformationFinished()

setTransformationSuccess

protected void setTransformationSuccess(boolean success)
                                 throws FileNotFoundException,
                                        IOException
Set if the transformation was successfully completed. Must be called when the transformation is finished. Also deletes the source folder in the workspace.

Parameters:
success - if the transformation was completed successfully
Throws:
FileNotFoundException - if the workspace does not exist
IOException - if the workspace configuration file cannot be read or written

getId

public String getId()
Returns:
the workspace ID

getWorkspace

public File getWorkspace()
Returns:
the workspace folder

getTargetFolder

public File getTargetFolder()
Get the target folder. This folder holds the transformation results after the transformation is finished and successful.

Returns:
the target folder
See Also:
isTransformationFinished(), isTransformationSuccessful()

getSourceFolder

public File getSourceFolder()
Get the source folder. Files placed in this folder will be deleted after the transformation has finished.

Returns:
the source folder

getReportFile

public File getReportFile()
Get the report file. It holds information about the finished transformation.

Returns:
the report file
See Also:
isTransformationFinished()

delete

public void delete()
Delete the workspace


Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d