EntityManager em = null;
try {
em = ResourceUtils.getEntityManager();
em.getTransaction().begin();
Query q;
QueryGenerator generator;
switch (type) {
case EXPERIMENT_INPUT:
generator = new QueryGenerator(EXPERIMENT_INPUT);
generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case EXPERIMENT_OUTPUT:
generator = new QueryGenerator(EXPERIMENT_OUTPUT);
generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case WORKFLOW_NODE_DETAIL:
generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case ERROR_DETAIL:
generator = new QueryGenerator(ERROR_DETAIL);
generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case STATUS:
generator = new QueryGenerator(STATUS);
generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case CONFIG_DATA:
generator = new QueryGenerator(CONFIG_DATA);
generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case COMPUTATIONAL_RESOURCE_SCHEDULING:
generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case ADVANCE_INPUT_DATA_HANDLING:
generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case ADVANCE_OUTPUT_DATA_HANDLING:
generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case QOS_PARAM:
generator = new QueryGenerator(QOS_PARAMS);
generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
default:
logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
break;