List of usage examples for org.hibernate Session saveOrUpdate
void saveOrUpdate(Object object);
From source file:com.globalsight.everest.costing.CostingEngineLocal.java
License:Apache License
private void setEstimatedAmountOfWorkInJob(long p_jobId, int p_unitOfWork, float p_amount, int p_costType) throws CostingException { Session session = null; Transaction transaction = null;/*from w w w . j a va2 s . c om*/ try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); // find all tasks with rates of the particular unit of work Collection tasks = getTaskManager().getTasks(p_jobId, new Integer(p_unitOfWork), new Integer(p_costType)); // loop through them and create/set the AmountOfWork for (Iterator taskI = tasks.iterator(); taskI.hasNext();) { Task t = (Task) taskI.next(); AmountOfWork aow = t.getAmountOfWork(new Integer(p_unitOfWork)); if (aow != null) // not new { aow.setEstimatedAmount(p_amount); t.setAmountOfWork(aow); } else // is new { Rate r = getActualRateToBeUsed(t); if (r == null) { if ((t.getExpenseRate() != null) && ((Integer) t.getExpenseRate().getRateType()).intValue() == p_unitOfWork) { aow = t.getExpenseRate().createAmountOfWork(); } else { if ((t.getRevenueRate() != null) && ((Integer) t.getRevenueRate().getRateType()).intValue() == p_unitOfWork) { aow = t.getRevenueRate().createAmountOfWork(); } } } else { // if the rate isn't the right type then look to the // revenue if (r.getRateType().intValue() != p_unitOfWork) { // if the actual rate to be used isn't of the right // type - then // check if it applies to the revenue if ((t.getRevenueRate() != null) && ((Integer) t.getRevenueRate().getRateType()).intValue() == p_unitOfWork) { aow = t.getRevenueRate().createAmountOfWork(); } } else { aow = r.createAmountOfWork(); } } if (aow != null) // if one created - because valid { aow.setEstimatedAmount(p_amount); t.setAmountOfWork(aow); } } session.saveOrUpdate(t); } transaction.commit(); } catch (Exception e) { if (transaction != null) { transaction.rollback(); } c_logger.error("Failed to set the estimated amount " + p_amount + " of work of type " + p_unitOfWork + " on job " + p_jobId, e); String args[] = { Float.toString(p_amount), Integer.toString(p_unitOfWork), Long.toString(p_jobId) }; throw new CostingException(CostingException.MSG_FAILED_TO_SET_AOW_IN_JOB, args, e); } finally { if (session != null) { // session.close(); } } }
From source file:com.globalsight.everest.costing.CostingEngineLocal.java
License:Apache License
/** * Calculate the cost of a job./*from w w w. j av a 2 s .c o m*/ */ private Cost calculateCost(Job p_job, Currency p_currency, boolean p_recalculateJob, Session p_session, int p_costType, boolean p_isJobComplete, boolean p_recalculateWorkflows) throws CostingException { // get the cost for the job Cost totalCost = getCost(p_job, p_costType); totalCost = (Cost) p_session.get(Cost.class, totalCost.getIdAsLong()); p_currency = (Currency) p_session.get(Currency.class, p_currency.getIdAsLong()); totalCost = totalCost.convert(p_currency); totalCost.isUseInContext = PageHandler.isInContextMatch(p_job); // if the cost should be recalculated if (p_recalculateJob && !p_isJobComplete) { // clear out the estimated and actual costs to start re-calculating. totalCost.setEstimatedCost(Cost.ZERO_COST); totalCost.setNoUseEstimatedCost(Cost.ZERO_COST); totalCost.setDefaultContextEstimatedCost(Cost.ZERO_COST); totalCost.setActualCost(Cost.ZERO_COST); totalCost.setType(p_costType); CostByWordCount jobCostByWordCount = new CostByWordCount(totalCost); boolean hasWordCountCostBreakdown = false; for (Iterator i = p_job.getWorkflows().iterator(); i.hasNext();) { Workflow w = (Workflow) i.next(); if (!w.getState().equals(Workflow.CANCELLED) && !w.getState().equals(Workflow.IMPORT_FAILED)) { Cost workflowCost = calculateCost(w, p_currency, p_recalculateWorkflows, p_session, p_costType, false); // record every workflow's costWordCount, // and when need them in the workflow calculate cost, // don't calculate them again. totalCost.addworkflowCost(w.getId(), workflowCost); totalCost = totalCost.add(workflowCost); totalCost.isUseInContext = PageHandler.isInContextMatch(p_job); CostByWordCount workflowCostByWordCount = workflowCost.getCostByWordCount(); if (workflowCostByWordCount != null) { hasWordCountCostBreakdown = true; jobCostByWordCount.add(workflowCostByWordCount); } } } totalCost.calculateFinalCost(); if (hasWordCountCostBreakdown) { CostByWordCount j = totalCost.getCostByWordCount(); CostByWordCount cloneJ = null; if (j == null) { cloneJ = jobCostByWordCount; } else { cloneJ = j; cloneJ.set(jobCostByWordCount); } p_session.saveOrUpdate(cloneJ); totalCost.setCostByWordCount(cloneJ); } else { CostByWordCount j = totalCost.getCostByWordCount(); if (j != null) { totalCost.setCostByWordCount(null); p_session.delete(j); } } } else { // else :: the cost is fine, only load workflow cost for usage. for (Iterator wfIter = p_job.getWorkflows().iterator(); wfIter.hasNext();) { Workflow wf = (Workflow) wfIter.next(); Cost wfCost = getCost(wf, p_costType); totalCost.addworkflowCost(wf.getId(), wfCost); } } p_session.saveOrUpdate(totalCost); return totalCost; }
From source file:com.globalsight.everest.costing.CostingEngineLocal.java
License:Apache License
/** * Calculate the cost of a workflow.//from ww w . j a v a2 s. com */ private Cost calculateCost(Workflow p_workflow, Currency p_currency, boolean p_recalculate, Session p_session, int p_costType, boolean p_recalcFinishedWorkflow) throws CostingException { try { // get the cost Cost totalCost = getCost(p_workflow, p_costType); totalCost = (Cost) p_session.get(Cost.class, totalCost.getIdAsLong()); p_currency = (Currency) p_session.get(Currency.class, p_currency.getIdAsLong()); totalCost = totalCost.convert(p_currency); totalCost.isUseInContext = PageHandler.isInContextMatch(p_workflow.getJob()); boolean completeWorkflow = (p_workflow.getState().equals(Workflow.EXPORTED) || p_workflow.getState().equals(Workflow.EXPORT_FAILED) || p_workflow.getState().equals(Workflow.ARCHIVED)); // if the cost should be recalculated if ((p_recalculate && !completeWorkflow) || (p_recalcFinishedWorkflow && completeWorkflow)) { // clear out the estimated and actual // since these will be recalculated totalCost.setEstimatedCost(Cost.ZERO_COST); totalCost.setNoUseEstimatedCost(Cost.ZERO_COST); totalCost.setDefaultContextEstimatedCost(Cost.ZERO_COST); totalCost.setActualCost(Cost.ZERO_COST); totalCost.setType(p_costType); // get all the task ids for the path in the workflow long[] taskIds = getWorkflowServer().taskIdsInDefaultPath(p_workflow.getId()); Hashtable tasks = null; tasks = ((WorkflowImpl) p_workflow).getTasks(); CostByWordCount workflowCostbyWordCount = new CostByWordCount(totalCost); boolean hasWordCountCostBreakdown = false; for (int i = 0; i < taskIds.length; i++) { Task t = (Task) tasks.get(new Long(taskIds[i])); // if they are in the process of being deleted they will be // NULL if (t != null) { Cost taskCost = calculateCost(t, p_currency, p_recalculate, p_session, p_costType, p_recalcFinishedWorkflow); CostByWordCount taskCostByWordCount = taskCost.getCostByWordCount(); totalCost.addTaskCost(t.getId(), taskCost); // totalCost.isUseInContext = p_workflow.getJob() // .getL10nProfile().getTranslationMemoryProfile() // .getIsContextMatchLeveraging(); totalCost.isUseInContext = PageHandler.isInContextMatch(p_workflow.getJob()); totalCost = totalCost.add(taskCost); if (taskCostByWordCount != null) { hasWordCountCostBreakdown = true; workflowCostbyWordCount.add(taskCostByWordCount); } } } totalCost.calculateFinalCost(); if (hasWordCountCostBreakdown) { // now see if there is an existing workflow cost breakdown CostByWordCount w = totalCost.getCostByWordCount(); CostByWordCount cloneWorkflowCostByWordCount = null; if (w == null) { cloneWorkflowCostByWordCount = workflowCostbyWordCount; } else { cloneWorkflowCostByWordCount = w; cloneWorkflowCostByWordCount.set(workflowCostbyWordCount); } p_session.saveOrUpdate(cloneWorkflowCostByWordCount); totalCost.setCostByWordCount(cloneWorkflowCostByWordCount); } else { CostByWordCount w = totalCost.getCostByWordCount(); if (w != null) { // delete this cost totalCost.setCostByWordCount(null); p_session.delete(w); } } } p_session.saveOrUpdate(totalCost); // else just return the cost that is set return totalCost; } catch (CostingException e) { throw e; } catch (Exception e) { c_logger.error( "WorkflowException when getting tasks to calculate cost for workflow " + p_workflow.getId(), e); String args[] = { Long.toString(p_workflow.getId()) }; throw new CostingException(CostingException.MSG_FAILED_TO_GET_TASKS_FOR_COSTING, args, e); } }
From source file:com.globalsight.everest.costing.CostingEngineLocal.java
License:Apache License
/** * Calculate the cost of a task.//ww w . j a v a 2 s. c o m */ private Cost calculateCost(Task p_task, Currency p_currency, boolean p_recalculate, Session p_session, int p_costType, boolean p_recalcFinishedWorkflow) throws CostingException, RemoteException, TaskException, EnvoyServletException { try { Task t = (TaskImpl) p_session.get(TaskImpl.class, new Long(p_task.getId())); Cost cost = getCost(t, p_costType); cost = (Cost) p_session.get(Cost.class, cost.getIdAsLong()); boolean addToActualCost = false; // Cost costClone = (Cost) p_tlUow.registerObject(cost); // Currency currClone = (Currency) // p_tlUow.registerObject(p_currency); Currency currClone = (Currency) p_session.get(Currency.class, new Long(p_currency.getId())); boolean isTaskAccepted = false; String userId = null; userId = p_task.getAcceptor(); if (userId != null && !userId.equals("0")) { isTaskAccepted = true; } // If the task is not yet ACCEPTED the don't // consider it for Actual Cost calculations. // For some reason when this part is reached from // JobDetails page the getState() does not return // state as accpeted. // Note that the completed state is picked up properly. // Even when a state is not accepted getstate() returns // -1 => TASK_COMPLETED. So it's necessary to verify // accepted and completed dates exist to avoid any // ambiguity. if (isTaskAccepted || (t.getState() == WorkflowConstants.TASK_COMPLETED && t.getAcceptedDate() != null && t.getCompletedDate() != null)) { addToActualCost = true; } else { addToActualCost = false; } // convert to the correct currency cost = cost.convert(currClone); // if the workflow is complete then no reason to recalculate task // the task can be complete though and still need to be costed Workflow wf = t.getWorkflow(); // don't check localized since the last task needs to be calculated // and may not happen till the workflow is moved to localized boolean completeWorkflow = (wf.getState().equals(Workflow.EXPORTED) || wf.getState().equals(Workflow.EXPORT_FAILED) || wf.getState().equals(Workflow.ARCHIVED)); // if the cost should be recalculated if ((p_recalculate && !completeWorkflow) || (p_recalcFinishedWorkflow && completeWorkflow)) { // clear out the costs that will be recalculated cost.setEstimatedCost(Cost.ZERO_COST); cost.setNoUseEstimatedCost(Cost.ZERO_COST); cost.setDefaultContextEstimatedCost(Cost.ZERO_COST); cost.setActualCost(Cost.ZERO_COST); cost.setType(p_costType); Rate r = null; if (p_costType == Cost.EXPENSE) { r = getActualRateToBeUsed(t); if (r == null) { r = t.getExpenseRate(); } } else if (p_costType == Cost.REVENUE) { r = t.getRevenueRate(); } if (r != null) { if (r.getRateType().equals(Rate.UnitOfWork.HOURLY)) { cost = calculateByHour(cost, r, t.getAmountOfWork(Rate.UnitOfWork.HOURLY), addToActualCost); } else if (r.getRateType().equals(Rate.UnitOfWork.PAGE_COUNT)) { // get the actual number of pages in the job - used as // the // default if it hasn't been set yet. float defaultNumOfPages = getEstimatedAmountOfWorkInJob(t.getWorkflow().getJob().getId(), Rate.UnitOfWork.PAGE_COUNT.intValue(), p_costType); cost = calculateByPageCount(cost, r, t.getAmountOfWork(Rate.UnitOfWork.PAGE_COUNT), (int) defaultNumOfPages, addToActualCost); } else if (r.getRateType().equals(Rate.UnitOfWork.WORD_COUNT) || r.getRateType().equals(Rate.UnitOfWork.WORD_COUNT_BY)) { cost = calculateByWordCount(p_session, cost, r, t.getWorkflow(), addToActualCost); } else if (r.getRateType().equals(Rate.UnitOfWork.FIXED)) { cost = calculateByFixed(cost, r, addToActualCost); } else { // invalid - so just leave as '0' c_logger.error("Invalid rate type " + r.getRateType() + " left cost as '0' when calculating cost."); } } // else - no rate - this is OK cost.calculateFinalCost(); } cost.isUseInContext = PageHandler.isInContextMatch(wf.getJob()); // else cost is fine p_session.saveOrUpdate(cost); return cost; } catch (TaskException te) { throw new EnvoyServletException(te); } catch (CostingException e) { throw e; } catch (Exception ge) { throw new EnvoyServletException(ge); } }
From source file:com.globalsight.everest.costing.CostingEngineLocal.java
License:Apache License
/** * Return the cost using the word count rate. *//*from w ww .j a v a 2 s. c o m*/ private Cost calculateByWordCount(Session p_session, Cost p_cost, Rate p_rate, Workflow p_workflow, boolean addToActualCost) { Currency rateCurrency = p_rate.getCurrency(); Currency costCurrency = p_cost.getCurrency(); boolean isUseInContext = PageHandler.isInContextMatch(p_workflow.getJob()); if (p_rate.getRateType().equals(Rate.UnitOfWork.WORD_COUNT) || p_rate.getRateType().equals(Rate.UnitOfWork.WORD_COUNT_BY)) { // get word counts // Note: the adjusted workflow word counts (which include cross-file // repetition analysis) are stored on the workflow. // These adjusted word counts are what we want to cost off of. // all repetitions int repetitionCount = p_workflow.getRepetitionWordCount(); // The fuzzy match category int inContextMatchCount = p_workflow.getInContextMatchWordCount(); int noUseInContextMatchCount = p_workflow.getNoUseInContextMatchWordCount(); int totalExactMatchWordCount = p_workflow.getTotalExactMatchWordCount(); // The exact match category int contextMatchCount = p_workflow.getContextMatchWordCount(); int segmentTmMatchCount = p_workflow.getSegmentTmWordCount(); int defaultContextSegmentTmMatchCount = totalExactMatchWordCount - contextMatchCount; int lowFuzzyMatchCount = p_workflow.getThresholdLowFuzzyWordCount(); int medFuzzyMatchCount = p_workflow.getThresholdMedFuzzyWordCount(); int medHiFuzzyMatchCount = p_workflow.getThresholdMedHiFuzzyWordCount(); int hiFuzzyMatchCount = p_workflow.getThresholdHiFuzzyWordCount(); int noMatchCount = p_workflow.getThresholdNoMatchWordCount(); // The areas where calculations are done (multiply, add, subtract) // should be changed to use BigDecimal for the actual calculation. float noMatchCost = BigDecimalHelper.multiply(noMatchCount, p_rate.getNoMatchRate()); float repetitionCost = BigDecimalHelper.multiply(repetitionCount, p_rate.getRepetitionRate()); // Fuzzy Match Categories float lowFuzzyMatchCost = BigDecimalHelper.multiply(lowFuzzyMatchCount, p_rate.getLowFuzzyMatchRate()); float medFuzzyMatchCost = BigDecimalHelper.multiply(medFuzzyMatchCount, p_rate.getMedFuzzyMatchRate()); float medHiFuzzyMatchCost = BigDecimalHelper.multiply(medHiFuzzyMatchCount, p_rate.getMedHiFuzzyMatchRate()); float hiFuzzyMatchCost = BigDecimalHelper.multiply(hiFuzzyMatchCount, p_rate.getHiFuzzyMatchRate()); float inContextMatchCost = BigDecimalHelper.multiply(inContextMatchCount, p_rate.getInContextMatchRate()); float noUseInContextMatchCost = BigDecimalHelper.multiply(noUseInContextMatchCount, p_rate.getInContextMatchRate()); float totalExactMatchCost = BigDecimalHelper.multiply(totalExactMatchWordCount, p_rate.getSegmentTmRate()); // Exact Match float contextMatchCost = BigDecimalHelper.multiply(contextMatchCount, p_rate.getContextMatchRate()); float segmentTmMatchCost = BigDecimalHelper.multiply(segmentTmMatchCount, p_rate.getSegmentTmRate()); float defaultContextSegmentTmMatchCost = BigDecimalHelper.multiply(defaultContextSegmentTmMatchCount, p_rate.getSegmentTmRate()); // convert all the costs to the cost currency noMatchCost = Cost.convert(noMatchCost, rateCurrency, costCurrency); repetitionCost = Cost.convert(repetitionCost, rateCurrency, costCurrency); lowFuzzyMatchCost = Cost.convert(lowFuzzyMatchCost, rateCurrency, costCurrency); medFuzzyMatchCost = Cost.convert(medFuzzyMatchCost, rateCurrency, costCurrency); medHiFuzzyMatchCost = Cost.convert(medHiFuzzyMatchCost, rateCurrency, costCurrency); hiFuzzyMatchCost = Cost.convert(hiFuzzyMatchCost, rateCurrency, costCurrency); inContextMatchCost = Cost.convert(inContextMatchCost, rateCurrency, costCurrency); noUseInContextMatchCost = Cost.convert(noUseInContextMatchCost, rateCurrency, rateCurrency); totalExactMatchCost = Cost.convert(totalExactMatchCost, rateCurrency, rateCurrency); contextMatchCost = Cost.convert(contextMatchCost, rateCurrency, costCurrency); segmentTmMatchCost = Cost.convert(segmentTmMatchCost, rateCurrency, costCurrency); // The areas where calculations are done (multiply, add, subtract) // should be changed to use BigDecimal for the actual calculation. // Leverage In-Context Match float[] param = { noMatchCost, repetitionCost, lowFuzzyMatchCost, medFuzzyMatchCost, medHiFuzzyMatchCost, hiFuzzyMatchCost, // inContextMatchCost, contextMatchCost, segmentTmMatchCost // }; inContextMatchCost, segmentTmMatchCost }; float amount = BigDecimalHelper.add(param); // Leverage 100% Match float[] noUseParam = { noMatchCost, repetitionCost, lowFuzzyMatchCost, medFuzzyMatchCost, medHiFuzzyMatchCost, hiFuzzyMatchCost, // noUseInContextMatchCost, contextMatchCost, noUseInContextMatchCost, totalExactMatchCost }; float noUseAmount = BigDecimalHelper.add(noUseParam); // Leverage Default Match float[] defaultContextParam = { noMatchCost, repetitionCost, lowFuzzyMatchCost, medFuzzyMatchCost, medHiFuzzyMatchCost, hiFuzzyMatchCost, contextMatchCost, defaultContextSegmentTmMatchCost }; float defaultContextAmount = BigDecimalHelper.add(defaultContextParam); p_cost.setEstimatedCost(amount); p_cost.setNoUseEstimatedCost(noUseAmount); p_cost.setDefaultContextEstimatedCost(defaultContextAmount); CostByWordCount wordCountCost = p_cost.getCostByWordCount(); if (wordCountCost == null) { wordCountCost = new CostByWordCount(p_cost, repetitionCost, contextMatchCost, inContextMatchCost, segmentTmMatchCost, lowFuzzyMatchCost, medFuzzyMatchCost, medHiFuzzyMatchCost, hiFuzzyMatchCost, noMatchCost, noUseInContextMatchCost, totalExactMatchCost, defaultContextSegmentTmMatchCost); p_cost.setCostByWordCount(wordCountCost); p_session.save(wordCountCost); } else { CostByWordCount wordCountCost_temp = (CostByWordCount) p_session.get(CostByWordCount.class, wordCountCost.getIdAsLong()); wordCountCost_temp.setRepetitionCost(repetitionCost); wordCountCost_temp.setContextMatchCost(contextMatchCost); wordCountCost_temp.setInContextMatchCost(inContextMatchCost); wordCountCost_temp.setNoUseInContextMatchCost(noUseInContextMatchCost); wordCountCost_temp.setNoUseExactMatchCost(totalExactMatchCost); wordCountCost_temp.setSegmentTmMatchCost(segmentTmMatchCost); wordCountCost_temp.setLowFuzzyMatchCost(lowFuzzyMatchCost); wordCountCost_temp.setMedFuzzyMatchCost(medFuzzyMatchCost); wordCountCost_temp.setMedHiFuzzyMatchCost(medHiFuzzyMatchCost); wordCountCost_temp.setHiFuzzyMatchCost(hiFuzzyMatchCost); wordCountCost_temp.setNoMatchCost(noMatchCost); wordCountCost_temp.setDefaultContextExactMatchCost(defaultContextSegmentTmMatchCost); p_session.saveOrUpdate(wordCountCost_temp); p_cost.setCostByWordCount(wordCountCost_temp); } p_cost.isUseInContext = isUseInContext; if (addToActualCost) { p_cost.setActualCost((isUseInContext) ? amount : noUseAmount); } } return p_cost; }
From source file:com.globalsight.everest.cvsconfig.CVSFileProfileManagerLocal.java
License:Apache License
public void update(CVSFileProfile p_obj) { CVSFileProfile oldfp = null;//w w w .j a va 2 s. co m Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); oldfp = getCVSFileProfile(p_obj.getId()); if (oldfp != null) { oldfp.setModule(p_obj.getModule()); oldfp.setSourceLocale(p_obj.getSourceLocale()); oldfp.setFileExt(p_obj.getFileExt()); oldfp.setFileProfile(p_obj.getFileProfile()); } session.saveOrUpdate(oldfp); transaction.commit(); } catch (Exception e) { try { transaction.rollback(); c_logger.error(e.getMessage(), e); } catch (Exception e2) { } } }
From source file:com.globalsight.everest.cvsconfig.CVSServerManagerLocal.java
License:Apache License
public void updateServer(CVSServer p_server) throws RemoteException, CVSConfigException { Session session = null; Transaction transaction = null;//from w w w . j a v a 2s. c om try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); CVSServer oldSrv = getServer(p_server.getId()); if (oldSrv != null) { if (!oldSrv.getHostIP().equals(p_server.getHostIP()) || !oldSrv.getSandbox().equals(p_server.getSandbox()) || !oldSrv.getRepository().equals(p_server.getRepository())) { Set<CVSModule> modules = oldSrv.getModuleSet(); for (CVSModule m : modules) { if (m.isActive()) { m.setLastCheckout(null); session.saveOrUpdate(m); } } FileUtils.deleteAllFilesSilently(CVSUtil.getBaseDocRoot().concat(oldSrv.getSandbox())); CVSUtil.createFolder(p_server.getSandbox()); } oldSrv.setName(p_server.getName()); oldSrv.setProtocol(p_server.getProtocol()); oldSrv.setHostIP(p_server.getHostIP()); oldSrv.setHostPort(p_server.getHostPort()); oldSrv.setRepository(p_server.getRepository()); oldSrv.setLoginUser(p_server.getLoginUser()); oldSrv.setLoginPwd(p_server.getLoginPwd()); oldSrv.setSandbox(p_server.getSandbox()); oldSrv.setCVSRootEnv(p_server.getCVSRootEnv()); } session.saveOrUpdate(oldSrv); transaction.commit(); } catch (Exception e) { try { transaction.rollback(); } catch (Exception e2) { } } }
From source file:com.globalsight.everest.cvsconfig.CVSServerManagerLocal.java
License:Apache License
public void removeServer(long p_id) throws RemoteException, CVSConfigException { Session session = null; Transaction transaction = null;//from w w w.j av a 2 s. c om try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); CVSServer oldSrv = getServer(p_id); if (oldSrv != null) { oldSrv.setIsActive(false); session.saveOrUpdate(oldSrv); Set<CVSModule> modules = oldSrv.getModuleSet(); for (CVSModule m : modules) { removeModule(m.getId()); } } transaction.commit(); } catch (Exception e) { try { transaction.rollback(); } catch (Exception e2) { } } }
From source file:com.globalsight.everest.cvsconfig.CVSServerManagerLocal.java
License:Apache License
public void removeRepository(long p_id) throws RemoteException, CVSConfigException { Session session = null; Transaction transaction = null;/*from w w w . ja v a2 s. com*/ try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); CVSRepository oldSrv = getRepository(p_id); if (oldSrv != null) { oldSrv.setIsActive(false); session.saveOrUpdate(oldSrv); for (CVSModule m : oldSrv.getModuleSet()) removeModule(m.getId()); } transaction.commit(); } catch (Exception e) { try { transaction.rollback(); } catch (Exception e2) { } } }
From source file:com.globalsight.everest.cvsconfig.CVSServerManagerLocal.java
License:Apache License
public void removeModule(long p_id) throws RemoteException, CVSConfigException { Session session = null; Transaction transaction = null;/*w w w .ja v a2 s . c o m*/ try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); CVSModule oldSrv = getModule(p_id); if (oldSrv != null) { oldSrv.setIsActive(false); session.saveOrUpdate(oldSrv); } transaction.commit(); } catch (Exception e) { try { transaction.rollback(); } catch (Exception e2) { } } }