159 lines
4.2 KiB
Java
159 lines
4.2 KiB
Java
package org.gcube.common.workspacetaskexecutor.dataminer;
|
|
|
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
import org.gcube.common.workspacetaskexecutor.CheckableTask;
|
|
import org.gcube.common.workspacetaskexecutor.ConfigurableTask;
|
|
import org.gcube.common.workspacetaskexecutor.ExecutableTask;
|
|
import org.gcube.common.workspacetaskexecutor.TaskConfiguration;
|
|
import org.gcube.common.workspacetaskexecutor.WsUtil;
|
|
import org.gcube.common.workspacetaskexecutor.shared.ItemNotExecutable;
|
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.AlgorithmConfiguration;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
/**
|
|
* The Class WorkspaceDataMinerTaskExecute.
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* Apr 26, 2018
|
|
*/
|
|
public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<AlgorithmConfiguration>, ConfigurableTask<AlgorithmConfiguration>, CheckableTask<AlgorithmConfiguration>{
|
|
|
|
/** The logger. */
|
|
private static Logger logger = LoggerFactory.getLogger(WorkspaceDataMinerTaskExecutor.class);
|
|
|
|
private static WorkspaceDataMinerTaskExecutor INSTANCE = null;
|
|
|
|
public static final String WS_TASK_TASK_CONF = "WS-TASK.TASK-CONF";
|
|
|
|
private String usernameOwner;
|
|
|
|
|
|
/**
|
|
* Instantiates a new workspace data miner task executor.
|
|
*/
|
|
private WorkspaceDataMinerTaskExecutor() {
|
|
}
|
|
|
|
|
|
/**
|
|
* With owner.
|
|
*
|
|
* @param usernameOwner the username owner
|
|
*/
|
|
public void withOwner(String usernameOwner){
|
|
this.usernameOwner = usernameOwner;
|
|
}
|
|
|
|
|
|
/**
|
|
* Gets the single instance of WorkspaceDataMinerTaskExecutor.
|
|
*
|
|
* @return single instance of WorkspaceDataMinerTaskExecutor
|
|
*/
|
|
public static WorkspaceDataMinerTaskExecutor getInstance() {
|
|
if (INSTANCE == null) {
|
|
INSTANCE = new WorkspaceDataMinerTaskExecutor();
|
|
}
|
|
return INSTANCE;
|
|
}
|
|
|
|
|
|
/**
|
|
* Check owner.
|
|
*
|
|
* @throws Exception the exception
|
|
*/
|
|
private void checkOwner() throws Exception {
|
|
|
|
if(usernameOwner==null || usernameOwner.isEmpty())
|
|
throw new Exception("You must set a valid 'usernameOwner'. Using the method #withOwner");
|
|
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.gcube.common.workspacetaskexecutor.CheckableTask#checkItemExecutable(java.lang.String)
|
|
*/
|
|
@Override
|
|
public AlgorithmConfiguration checkItemExecutable(String itemId) throws ItemNotExecutable, Exception {
|
|
|
|
checkOwner();
|
|
WorkspaceItem item = WsUtil.getItem(usernameOwner, itemId);
|
|
String propConfig = WsUtil.getPropertyValue(item, WS_TASK_TASK_CONF);
|
|
|
|
if(propConfig==null)
|
|
throw new ItemNotExecutable("The item id "+itemId+" has not a "+TaskConfiguration.class.getSimpleName());
|
|
|
|
//ObjectMapper mapper = new ObjectMapper();
|
|
|
|
return null;
|
|
}
|
|
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.gcube.common.workspacetaskexecutor.ConfigurableTask#removeTaskConfig(java.lang.Object)
|
|
*/
|
|
@Override
|
|
public Boolean removeTaskConfig(String workspaceItemId) throws ItemNotExecutable, Exception {
|
|
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.gcube.common.workspacetaskexecutor.ConfigurableTask#addTaskConfig(java.lang.Object)
|
|
*/
|
|
@Override
|
|
public Boolean addTaskConfig(AlgorithmConfiguration config) throws ItemNotExecutable, Exception {
|
|
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#doRun(java.lang.String)
|
|
*/
|
|
@Override
|
|
public AlgorithmConfiguration doRun(String itemId)
|
|
throws ItemNotExecutable, Exception {
|
|
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#stopRun(java.lang.String)
|
|
*/
|
|
@Override
|
|
public Boolean stopRun(String itemId)
|
|
throws ItemNotExecutable, Exception {
|
|
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#monitorRunStatus(java.lang.String)
|
|
*/
|
|
@Override
|
|
public AlgorithmConfiguration monitorRunStatus(String itemId)
|
|
throws ItemNotExecutable, Exception {
|
|
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#registerCallbackForId(java.lang.String)
|
|
*/
|
|
@Override
|
|
public void registerCallbackForId(String itemId)
|
|
throws Exception {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
}
|