use of org.vcell.util.ProgrammingException in project vcell by virtualcell.
the class ClientTaskDispatcher method runTask.
/**
* call currentTask.run(hash) with log4j logging; check for required keys
* @param currentTask not null
* @param hash not null
* @param taskList current set of tasks being dispatched
* @throws Exception
*/
private static void runTask(AsynchClientTask currentTask, Hashtable<String, Object> hash, Collection<AsynchClientTask> taskList) throws Exception {
if (lg.isDebugEnabled()) {
String msg = "Thread " + Thread.currentThread().getName() + " calling task " + currentTask.getTaskName();
if (lg.isDebugEnabled()) {
Object obj = hash.get(STACK_TRACE_ARRAY);
StackTraceElement[] ste = BeanUtils.downcast(StackTraceElement[].class, obj);
if (ste != null) {
msg += '\n' + StringUtils.join(ste, '\n');
}
lg.debug(msg);
} else {
lg.debug(msg);
}
}
// check required elements present
StringBuilder sb = null;
for (KeyInfo requiredKey : currentTask.requiredKeys()) {
Object obj = hash.get(requiredKey.name);
if (obj == null) {
if (sb == null)
sb = initStringBuilder(currentTask);
sb.append("Missing required key " + requiredKey.name + '\n');
continue;
}
Class<?> foundClass = obj.getClass();
if (!requiredKey.clzz.isAssignableFrom(foundClass)) {
if (sb == null)
sb = initStringBuilder(currentTask);
sb.append("key " + requiredKey.name + " type " + foundClass.getName() + " not of required type " + requiredKey.clzz.getName());
sb.append('\n');
}
}
if (sb == null) {
// no problems found
currentTask.run(hash);
return;
}
sb.append("Prior tasks\n");
for (AsynchClientTask pt : taskList) {
if (pt == currentTask) {
break;
}
sb.append('\t' + pt.getTaskName() + '\n');
}
hash.put(HASH_DATA_ERROR, HASH_DATA_ERROR);
throw new ProgrammingException(sb.toString());
}
use of org.vcell.util.ProgrammingException in project vcell by virtualcell.
the class ChildWindowManager method findChildWindowManager.
/**
* @param component not null
* @return ChildWindowManager
* @throws ProgrammingException if unable to find ChildWindowManager
*/
public static ChildWindowManager findChildWindowManager(Component component) {
ManagedChild mc = LWNamespace.findOwnerOfType(ManagedChild.class, component);
if (mc != null) {
return mc.getChildWindowManager();
}
if (LG.isDebugEnabled()) {
LG.debug(ExecutionTrace.justClassName(component) + " does not have ManagedChild parent");
}
TopLevelWindow dw = LWNamespace.findOwnerOfType(TopLevelWindow.class, component);
if (dw != null) {
return dw.getChildWindowManager();
}
throw new ProgrammingException("ChildWindowManager.findChildWindowManager(Component) could not find a ChildWindowManager for component: " + component.getName() + " which is a " + component.getClass().getCanonicalName());
}
use of org.vcell.util.ProgrammingException in project vcell by virtualcell.
the class LegacySimContextTransformer method transform.
@Override
public SimContextTransformation transform(SimulationContext originalSimContext, MathMappingCallback mathMappingCallback, NetworkGenerationRequirements networkGenerationRequirements) {
SimulationContext transformedSimContext;
try {
transformedSimContext = (SimulationContext) BeanUtils.cloneSerializable(originalSimContext);
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
throw new RuntimeException("unexpected exception: " + e.getMessage());
}
try {
StructureMapping structureMapping = transformedSimContext.getGeometryContext().getStructureMappings()[0];
StructureSizeSolver.updateAbsoluteStructureSizes(transformedSimContext, structureMapping.getStructure(), 1.0, structureMapping.getSizeParameter().getUnitDefinition());
} catch (Exception e) {
throw new ProgrammingException("exception updating sizes", e);
}
transformedSimContext.getModel().refreshDependencies();
transformedSimContext.refreshDependencies1(false);
ArrayList<ModelEntityMapping> entityMappings = new ArrayList<ModelEntityMapping>();
for (SpeciesContext sc : transformedSimContext.getModel().getSpeciesContexts()) {
SpeciesContext origSpeciesContext = originalSimContext.getModel().getSpeciesContext(sc.getName());
ModelEntityMapping em = new ModelEntityMapping(origSpeciesContext, sc);
entityMappings.add(em);
}
ModelEntityMapping[] modelEntityMappings = entityMappings.toArray(new ModelEntityMapping[0]);
return new SimContextTransformation(originalSimContext, transformedSimContext, modelEntityMappings);
}
use of org.vcell.util.ProgrammingException in project vcell by virtualcell.
the class AsynchClientTask method setFinalWindow.
/**
* set final window to be raised
* @param hashTable non null
* @param cntr non null
* @throws ProgrammingException if more than one set in the same hash
*/
protected void setFinalWindow(Hashtable<String, Object> hashTable, Container cntr) {
Objects.requireNonNull(cntr);
Window w = GuiUtils.getWindowForComponent(cntr);
if (w != null) {
ClientTaskDispatcher.setFinalWindow(hashTable, () -> w.toFront());
return;
}
throw new ProgrammingException("Container " + cntr.getName() + " has no window parent");
}
use of org.vcell.util.ProgrammingException in project vcell by virtualcell.
the class VCReactionProxy method factory.
/**
* get proxy for Reaction type
* @param reaction not null
* @return proxy
* @throws ProgrammingException unknown type
*/
public static VCReactionProxy factory(ReactionStep reaction) {
VCAssert.assertValid(reaction);
SimpleReaction sr = BeanUtils.downcast(SimpleReaction.class, reaction);
if (sr != null) {
return new Simple(sr);
}
FluxReaction fr = BeanUtils.downcast(FluxReaction.class, reaction);
if (fr != null) {
return new Flux(fr);
}
throw new ProgrammingException("Unknown reaction type " + ExecutionTrace.justClassName(reaction));
}
Aggregations