User 247c00dc1d
14-06-2016 13:42:23
Hello, when I run the script, which imports data from one table to another, time to time appears error:
EROROR Failed to load ID 8099 org.springframework.dao.DataAccessResourceFailureException: No current connection.; SQL []; No current connection.; nested exception is java.sql.SQLNonTransientConnectionException: No current connection.
EROROR Failed to load ID 8100 org.springframework.dao.DataAccessResourceFailureException: No current connection.; SQL []; No current connection.; nested exception is java.sql.SQLNonTransientConnectionException: No current connection.
EROROR Failed to load ID 8101 org.springframework.dao.DataAccessResourceFailureException: No current connection.; SQL []; No current connection.; nested exception is java.sql.SQLNonTransientConnectionException: No current connection.
import com.im.commons.progress.*
import com.im.df.api.chem.MarvinStructure
import chemaxon.jep.Evaluator
import chemaxon.jep.context.MolContext
import chemaxon.formats.MolExporter
def parent = dataTree.rootVertex.entity
def rs = parent.schema.dataProvider.getDefaultResultSet(dataTree, false, DFEnvironmentRO.DEV_NULL)
def parentVS = rs.getVertexState(dataTree.rootVertex)
def molIDs = parentVS.getIds()
println "Найдено $molIDs.size строк (IDs) для экспорта"
def protoEdge = dataTree.rootVertex.edges.find { it.destination.entity.name == 'test' }
def protoEntity = protoEdge.destination.entity
def protoEdp = protoEntity.schema.dataProvider.getEntityDataProvider(protoEntity)
def testresult1 = protoEntity.fields.items.find {it.name == "testresult1"}
def testresult2 = protoEntity.fields.items.find {it.name == "testresult2"}
def Description = protoEntity.fields.items.find {it.name == "Description"}
//##############################################################################################################
def name = parent.fields.items.find { it.name == "name" }
def testresult1 = parent.fields.items.find { it.name == "testresult1" }
def testresult2 = parent.fields.items.find { it.name == "testresult2" }
def m1 = parent.fields.items.find { it.name == "A" }def m2 = parent.fields.items.find { it.name == "B" }def m3 = parent.fields.items.find { it.name == "C" }
i=0
try {
def lock = protoEdp.lockable.withLock('inserting data'){ envRW ->
molIDs.each { id ->
i++
// stop if the script is terminated
if (env.getFeedback().isCancelled())
{
def msg = "Exporting data to file interupted in the record $i!"
println msg
throw new InterruptedException(msg)
}
try {
//Fetch in the molecule from the structures table
def data = parentVS.getData([id], DFEnvironmentRO.DEV_NULL)
getMol = data[id][molFld.id]
nativeMol = getMol.getNative()
def nativeStr = MolExporter.exportToFormat(nativeMol, "smiles")
def vname = data[id][name.id]
def vtestresult1 = data[id][testresult1.id]
def vtestresult2 = data[id][testresult2.id]def m1g = data[id][m1.id]def m2g = data[id][m2.id]def m3g = data[id][m3.id]
def masses = [m1g, m2g, m3g]
masses.each { m ->
vals = [:]
if (m)
{
vals.putAt(Description.id, vname)
vals.putAt(testresult1.id, vtestresult1)
vals.putAt(testresult2.id, vtestresult2)
protoEdp.insert(vals, null, envRW)
}
i++
}
} catch (Exception exc) {
println "EROROR Failed to load ID $id ${exc.toString()}"
}
}
}} finally {
}