Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.quinsoft.zeidon.standardoe.AbstractTaskQualification Maven / Gradle / Ivy
package com.quinsoft.zeidon.standardoe;
import java.util.EnumSet;
import java.util.List;
import org.apache.commons.io.IOUtils;
import com.quinsoft.zeidon.ActivateFlags;
import com.quinsoft.zeidon.ActivateOptions;
import com.quinsoft.zeidon.Application;
import com.quinsoft.zeidon.CacheMap;
import com.quinsoft.zeidon.DeserializeOi;
import com.quinsoft.zeidon.StreamReader;
import com.quinsoft.zeidon.TaskQualification;
import com.quinsoft.zeidon.UnknownLodDefException;
import com.quinsoft.zeidon.View;
import com.quinsoft.zeidon.ZeidonException;
import com.quinsoft.zeidon.ZeidonLogger;
import com.quinsoft.zeidon.objectdefinition.LodDef;
import com.quinsoft.zeidon.utils.CacheMapImpl;
abstract class AbstractTaskQualification implements TaskQualification
{
private final Application app;
private CacheMap cacheMap;
AbstractTaskQualification( Application app )
{
this .app = app;
}
@Override
public abstract TaskImpl getTask () ;
@Override
public ViewImpl activateEmptyObjectInstance (String lodDefName) throws UnknownLodDefException
{
LodDef lodDef = getApplication().getLodDef( getTask(), lodDefName );
return activateEmptyObjectInstance( lodDef );
}
@Override
public JavaObjectEngine getObjectEngine ()
{
return getTask().getObjectEngine();
}
@Override
public ViewImpl activateEmptyObjectInstance ( String lodDefName, Application app ) throws UnknownLodDefException
{
LodDef lodDef = app.getLodDef( getTask(), lodDefName );
return activateEmptyObjectInstance( lodDef );
}
@Override
public ViewImpl activateEmptyObjectInstance ( String lodDefName, String appName ) throws UnknownLodDefException
{
LodDef lodDef = getApplication( appName ).getLodDef( getTask(), lodDefName );
return activateEmptyObjectInstance( lodDef );
}
@Override
public ViewImpl activateEmptyObjectInstance (LodDef lodDef)
{
ViewImpl view = new ViewImpl( getTask(), lodDef );
return view;
}
@Override
public View activateObjectInstance (String lodDefName, View qual, EnumSet control ) throws UnknownLodDefException
{
LodDef lodDef = getApplication().getLodDef( getTask(), lodDefName );
ActivateOptions options = new ActivateOptions( getTask() );
options.setLodDef( lodDef );
options.setQualificationObject( qual );
options.setActivateFlags( control );
return activateObjectInstance( options );
}
@Override
public View activateObjectInstance (LodDef lodDef, View qual, EnumSet control )
{
ActivateOptions options = new ActivateOptions( getTask() );
options.setLodDef( lodDef );
options.setQualificationObject( qual );
options.setActivateFlags( control );
return activateObjectInstance( options );
}
@Override
public View activateObjectInstance ( ActivateOptions options ) throws UnknownLodDefException
{
ActivateObjectInstance activator = new ActivateObjectInstance( getTask(), options );
return activator.activate();
}
@Override
public View activateObjectInstance ( String lodDefName, View qual, ActivateOptions options )
{
LodDef lodDef = getApplication().getLodDef( getTask(), lodDefName );
options.setLodDef( lodDef );
options.setQualificationObject( qual );
return activateObjectInstance( options );
}
@Override
public Application getApplication ()
{
return app;
}
@Override
public Application getApplication ( String appName )
{
return getTask().getObjectEngine().getApplication( appName );
}
@Override
public ZeidonLogger log ()
{
return getTask().log();
}
@Override
public ZeidonLogger dblog ()
{
return getTask().dblog();
}
@Override
public View activateOiFromFile ( String lodDefName,
String filename )
{
return activateOiFromFile( lodDefName, filename, null );
}
@Override
public View activateOiFromFile ( String lodDefName,
String filename,
EnumSet control) throws UnknownLodDefException
{
LodDef lodDef = getApplication().getLodDef( getTask(), lodDefName );
return activateOiFromFile( lodDef, filename, control );
}
@Override
public View activateOiFromFile ( LodDef lodDef,
String filename,
EnumSet control )
{
return new DeserializeOi( this )
.fromFile( filename )
.setLodDef( lodDef )
.setFlags( control )
.activateFirst();
}
@Override
public List activateOisFromStream ( DeserializeOi options ) throws UnknownLodDefException
{
try
{
StreamReader activator = options.getStreamReader();
if ( activator == null )
{
switch ( options.getFormat() )
{
case POR:
activator = new ActivateOiFromPorStream( );
break ;
case JSON:
activator = new ActivateOisFromJsonStream( );
break ;
case XML:
activator= new ActivateOisFromXmlStream();
break ;
case CSV:
activator= new ActivateOisFromCsv();
break ;
default :
throw new ZeidonException( "Unknown stream type %s" , options.getFormat() );
}
}
return activator.readFromStream( options );
}
finally
{
if ( options.isCloseStream() )
IOUtils.closeQuietly( options.getInputStream() );
}
}
protected String normalizeGroup ( String group )
{
if ( group.startsWith( "[" ) )
group = group.substring( 1 , group.length() - 1 );
return group;
}
@Override
public String readZeidonConfig (String group, String key)
{
return readZeidonConfig( group, key, null );
}
@Override
public String readZeidonConfig (String group, String key, String defaultValue)
{
return readZeidonConfig( getApplication(), group, key, defaultValue );
}
@Override
public String readZeidonConfig (Application application, String group, String key, String defaultValue)
{
return getTask().readZeidonConfig( application, group, key, defaultValue );
}
@Override
public String readZeidonConfig ( String application, String group, String key, String defaultValue)
{
return readZeidonConfig( getApplication( application ), group, key, defaultValue );
}
@Override
public synchronized void overrideZeidonConfig ( Application application, String group, String key, String value )
{
getTask().overrideZeidonConfig( application, group, key, value );
}
@Override
public void overrideZeidonConfig ( String appName, String group, String key, String value )
{
overrideZeidonConfig( getApplication( appName ), group, key, value );
}
@Override
public String getTempDirectory ()
{
return getTask().getTempDirectory();
}
public synchronized CacheMap getCacheMap ()
{
if ( cacheMap == null )
cacheMap = new CacheMapImpl();
return cacheMap;
}
@Override
public DeserializeOi deserializeOi ()
{
return new DeserializeOi( this );
}
}