perform-service_broken/src/main/java/org/gcube/application/perform/service/engine/ImporterImpl.java

89 lines
2.7 KiB
Java

package org.gcube.application.perform.service.engine;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import org.gcube.application.perform.service.LocalConfiguration;
import org.gcube.application.perform.service.engine.model.ISQueryDescriptor;
import org.gcube.application.perform.service.engine.model.importer.ImportRequest;
import org.gcube.application.perform.service.engine.model.importer.ImportRoutineDescriptor;
import org.gcube.application.perform.service.engine.model.importer.ImportTicket;
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ImporterImpl implements Importer {
private static ISQueryDescriptor isQueryDescriptor=null;
@Synchronized
private ISQueryDescriptor getISQueryDescriptor() {
if(isQueryDescriptor==null) {
isQueryDescriptor=
new ISQueryDescriptor(
LocalConfiguration.getProperty(LocalConfiguration.MAPPING_DB_ENDPOINT_NAME), null,
LocalConfiguration.getProperty(LocalConfiguration.MAPPING_DB_ENDPOINT_CATEGORY));
}
return isQueryDescriptor;
}
public void init() {
log.info("Initializing IMPORTER");
DataBaseManager db=DataBaseManager.get(getISQueryDescriptor());
Connection conn=db.getConnection();
PreparedStatement ps=conn.prepareStatement(ORPHAN_IMPORTS);
// set ps
ResultSet rsOrphans=ps.executeQuery();
long monitoredCount=0l;
while(rsOrphans.next()) {
// acquire
// monitor
}
log.info("Acquired {} import executions for monitoring",monitoredCount);
}
@Override
public ImportRoutineDescriptor importExcel(ImportRequest request) {
log.debug("Submitting {} ",request);
ComputationId id=submit(request);
log.debug("Registering {} computationID {} ",request,id);
ImportRoutineDescriptor desc=register(id,request);
log.debug("Monitoring {} computationID {} ",desc,id);
monitor(id,desc);
return getDescriptorById(desc.getId());
}
private void monitor(ComputationId computationId,ImportRoutineDescriptor desc) {
throw new RuntimeException("IMPLEMENT THIS SHIT");
}
private ComputationId submit(ImportRequest request) {
throw new RuntimeException("IMPLEMENT THIS SHIT");
}
private ImportRoutineDescriptor register(ComputationId computationId,ImportRequest request) {
throw new RuntimeException("IMPLEMENT THIS SHIT");
}
private ImportRoutineDescriptor getDescriptorById(Long id) {
throw new RuntimeException("IMPLEMENT THIS SHIT");
}
@Override
public List<ImportRoutineDescriptor> getDescriptors(ImportTicket ticket) {
// TODO Auto-generated method stub
return null;
}
}