Java Code Examples for ims.domain.exceptions.UniqueKeyViolationException

The following are top voted examples for showing how to use ims.domain.exceptions.UniqueKeyViolationException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: AvoinApotti   File: OcsIfInboundImpl.java   View source code 6 votes vote down vote up
public void saveLocation(IfLocParentVo location) throws StaleObjectException, UniqueKeyViolationException
{
	if (!location.isValidated())
		throw new DomainRuntimeException("Location not Validated.");

	DomainFactory factory = getDomainFactory();

	Location doLocation = IfLocParentVoAssembler.extractLocation(factory, location);

	try
	{
		factory.save(doLocation);
	}
	catch (UnqViolationUncheckedException e)
	{
		String dupMessage = Keywords.checkDuplicateTaxonomy(factory, doLocation, "codeMappings", location.getCodeMappings(), "getName");
		if(dupMessage != null)
			throw new UniqueKeyViolationException(dupMessage);

		throw new UniqueKeyViolationException("An Location with this name already exists, Please change", e);			
	}
	return;		
}
 
Example 2
Project: AvoinApotti   File: OPDEDClinicNotesImpl.java   View source code 6 votes vote down vote up
public void saveOPDEDVo(ims.generalmedical.vo.OPDErectDysfxnVo voOPDED) throws StaleObjectException, UniqueKeyViolationException
{
	// Ensure the value object has been validated
	if (!voOPDED.isValidated())
		throw new DomainRuntimeException("OPD Erectile Dysfunction has not been validated");

	DomainFactory factory = getDomainFactory();
	if (voOPDED.getID_OPDErectDysfxn() == null)//Inserting a record
	{
		StringBuffer hql = new StringBuffer();
		hql.append("from OPDErectDysfxn as o where o.careContext.id = :CCID and o.isRIE is null");
		java.util.List list = getDomainFactory().find(hql.toString(), "CCID",voOPDED.getCareContext().getID_CareContext());
		if (list == null || list.size() > 0)
			throw new UniqueKeyViolationException(" The screen will be refreshed");
	}
	OPDErectDysfxn doOPDED = OPDErectDysfxnVoAssembler.extractOPDErectDysfxn(factory, voOPDED);
	factory.save(doOPDED);
	return;
}
 
Example 3
Project: AvoinApotti   File: ServiceImpl.java   View source code 6 votes vote down vote up
public void removeServiceActivity(ims.core.vo.ServiceActivityVo voServiceActivity) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException, ims.domain.exceptions.UniqueKeyViolationException
{
	DomainFactory factory = getDomainFactory();

	ServiceActivity doServiceActivity = ServiceActivityVoAssembler.extractServiceActivity(factory, voServiceActivity);
	try
	{
		factory.delete(doServiceActivity);
	}
	catch (DomainRuntimeException e) // SN: catching
										// DomainRuntimeException here as
										// this is what Hib is returning
										// with e.getCause() =
										// ConstrainViolationException
	{
		throw new UniqueKeyViolationException(e.getMessage());
	}
}
 
Example 4
Project: AvoinApotti   File: OPDFertilityCLinicImpl.java   View source code 6 votes vote down vote up
public void saveOPDFertClinicVo(OPDFertClinicVo voOPDFertClinic) throws StaleObjectException, UniqueKeyViolationException 
{
	// Ensure the value object has been validated
	if (!voOPDFertClinic.isValidated())
		throw new DomainRuntimeException("OPD Fertility Clinic has not been validated");
	
	DomainFactory factory = getDomainFactory();
	if (voOPDFertClinic.getID_OPDFertClinic() == null)//Inserting a record
	{
		StringBuffer hql = new StringBuffer();
		hql.append("from OPDFertClinic as o where o.careContext.id = :CCID and o.isRIE is null");
		java.util.List list = getDomainFactory().find(hql.toString(), "CCID",voOPDFertClinic.getCareContext().getID_CareContext());
		if (list == null || list.size() > 0)
			throw new UniqueKeyViolationException("A record exists for this Care Context, the screen will be refreshed");
	}
	OPDFertClinic doOPDFertClinic = OPDFertClinicVoAssembler.extractOPDFertClinic(factory, voOPDFertClinic);
	factory.save(doOPDFertClinic);
	
}
 
Example 5
Project: AvoinApotti   File: OPDMedExamImpl.java   View source code 6 votes vote down vote up
/**
* Save the MedExamGeneralVo
 * @throws UniqueKeyViolationException 
*/
public void saveMedExamGeneralVo(ims.generalmedical.vo.MedExamGeneralVo voMedExamGeneral) throws StaleObjectException, UniqueKeyViolationException
{
	// Ensure the value object has been validated
	if (!voMedExamGeneral.isValidated())
		throw new DomainRuntimeException("OPD Medical Exam has not been validated");
	
	DomainFactory factory = getDomainFactory();
	if (voMedExamGeneral.getID_ExamGen() == null)//Inserting a record
	{
		StringBuffer hql = new StringBuffer();
		hql.append("from ExamGen as e where e.careContext.id = :CCID and e.isRIE is null");
		java.util.List list = getDomainFactory().find(hql.toString(), "CCID",voMedExamGeneral.getCareContext().getID_CareContext());
		if (list == null || list.size() > 0)
			throw new UniqueKeyViolationException("A record exists for this Care Context, the screen will be refreshed");
	}
	ExamGen doMedExamGeneral = MedExamGeneralVoAssembler.extractExamGen(factory, voMedExamGeneral);
	factory.save(doMedExamGeneral);
	
	return;
}
 
Example 6
Project: AvoinApotti   File: MedSystemreviewImpl.java   View source code 6 votes vote down vote up
public void saveProblemsAdmis(MedicalProbOnAdmisVoCollection problemColl)throws StaleObjectException, UniqueKeyViolationException 
{

	if(problemColl == null)
		return;
	DomainFactory factory = getDomainFactory();
	if(problemColl != null)
		for(int i=0; i<problemColl.size(); i++)
		{
			MedicalProbOnAdmisVo voMedicalProbOnAdmis = problemColl.get(i);
			PatientProblem doMedicalProbOnAdmis = MedicalProbOnAdmisVoAssembler.extractPatientProblem(factory, voMedicalProbOnAdmis);
			doMedicalProbOnAdmis.setIsRIE(Boolean.TRUE);  //wdev-13525
			
			factory.save(doMedicalProbOnAdmis);
							
			
		}
	
}
 
Example 7
Project: AvoinApotti   File: Logic.java   View source code 6 votes vote down vote up
public boolean populateActivityFunctionDataFromScreen(ServiceVo voService) throws UniqueKeyViolationException
{
	boolean ret = false;
	if (checkForErrorsOnActivityFunction())
	{
		// update taxonomy contexts for last selected function and activity
		saveServiceActivityTaxonomy(voService);
		saveServiceFunctionTaxonomy(voService);

		// add/remove activities
		ret = saveServiceActivity();
		if (!ret)
			return ret;

		ret = saveServiceFunction();

		return ret;
	}

	return false;
}
 
Example 8
Project: AvoinApotti   File: AllergiesImpl.java   View source code 6 votes vote down vote up
public PatientNoAllergyInfoVo savePatientNoAllergyInfo(PatientNoAllergyInfoVo patientNoAllergyInfo) throws StaleObjectException, UniqueKeyViolationException 
{
	if(!patientNoAllergyInfo.isValidated())
	{
		throw new CodingRuntimeException("PatientNoAllergyInfoVo Value Object Alert has not been validated");
	}
	
	DomainFactory factory = getDomainFactory();
	PatientNoAllergyInfo doPatientNoAllergyInfo = PatientNoAllergyInfoVoAssembler.extractPatientNoAllergyInfo(factory, patientNoAllergyInfo);
		
	try
	{
		factory.save(doPatientNoAllergyInfo);
	} 
	catch(UnqViolationUncheckedException e)
	{		
		PatientNoAllergyInfo noAllergyInfo = PatientNoAllergyInfo.getPatientNoAllergyInfoFromPatient(factory, patientNoAllergyInfo.getPatient().getID_Patient());
		if (noAllergyInfo != null && noAllergyInfo.getId() != null && !(noAllergyInfo.getId().equals(patientNoAllergyInfo.getID_PatientNoAllergyInfo())))
		{
			throw new UniqueKeyViolationException("A No Known Allergy record already exists for this patient. Duplicates not allowed.", e);					
		}

		throw (e);
	}
	return (PatientNoAllergyInfoVoAssembler.create(doPatientNoAllergyInfo));		
}
 
Example 9
Project: AvoinApotti   File: GlossaryAdminImpl.java   View source code 6 votes vote down vote up
public GlossaryVo saveGlossary(GlossaryVo voGlossary) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	if (voGlossary == null)
		throw new CodingRuntimeException("Invalid argument: GlossaryVo is null");
	if (!voGlossary.isValidated())
		throw new DomainRuntimeException("Glossary VO not validated.");

	DomainFactory factory = getDomainFactory();
	Glossary domGlossary = GlossaryVoAssembler.extractGlossary(factory,voGlossary);
	try
	{
		factory.save(domGlossary);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("Text already exists within the system for this Glossary.", e);
	}

	return GlossaryVoAssembler.create(domGlossary);
}
 
Example 10
Project: AvoinApotti   File: HydrotherapyImpl.java   View source code 6 votes vote down vote up
public void saveHydroTherapy(HydrotherapyVo voHydrotherapy) throws StaleObjectException, UniqueKeyViolationException 
{
	if(!voHydrotherapy.isValidated())
		throw new DomainRuntimeException("This HydroTherapy has not been validated");

	//if a new Hydrotherapy record is created check if already exists a Hydrotherapy record for selected clinical contact in the database
	//must exist only one Hydrotherapy record per clinical contact
	if(voHydrotherapy.getID_Hydrotherapy() == null)
	{
		if(voHydrotherapy.getClinicalContactIsNotNull())
		{
			HydrotherapyVo tempvo = getHydroTherapy(voHydrotherapy.getClinicalContact(), false);
			if(tempvo != null)
				throw new DomainRuntimeException("A Hydrotherapy record already exists for selected Clinical Contact.");
		}
	}
	
	DomainFactory factory = getDomainFactory();
	Hydrotherapy doHydro = HydrotherapyVoAssembler.extractHydrotherapy(factory, voHydrotherapy);
	factory.save(doHydro);
	
}
 
Example 11
Project: AvoinApotti   File: CorrespondenceHeadersAdminImpl.java   View source code 6 votes vote down vote up
public ims.correspondence.vo.TemplateCategoryVo saveTemplateCategories(ims.correspondence.vo.TemplateCategoryVo voTemplateCategory) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException, ims.domain.exceptions.UniqueKeyViolationException 
{
	if (voTemplateCategory == null)
		throw new CodingRuntimeException("Invalid Argument: Template Category is null");
	if (!voTemplateCategory.isValidated())
		throw new DomainRuntimeException("TemplateCategoryVo not validated.");
	
	DomainFactory factory = getDomainFactory();
	
	
	TemplateCategory domTemplCategory = TemplateCategoryVoAssembler.extractTemplateCategory(factory, voTemplateCategory);

	try
	{
		factory.save(domTemplCategory);
	}
	catch (UnqViolationUncheckedException ue)
	{
		throw new UniqueKeyViolationException(ue.getMessage());
	}
	
	return TemplateCategoryVoAssembler.create(domTemplCategory);

	
}
 
Example 12
Project: AvoinApotti   File: GlossaryAdminConfigurationImpl.java   View source code 6 votes vote down vote up
public ims.correspondence.vo.GlossaryVo saveGlossary(ims.correspondence.vo.GlossaryVo voGlossary) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if (voGlossary == null)
		throw new CodingRuntimeException("Invalid argument: GlossaryVo is null");
	if (!voGlossary.isValidated())
		throw new DomainRuntimeException("Glossary VO not validated.");

	DomainFactory factory = getDomainFactory();
	Glossary domGlossary = GlossaryVoAssembler.extractGlossary(factory,voGlossary);
	try
	{
		factory.save(domGlossary);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("Text already exists within the system for this Glossary.", e);
	}

	return GlossaryVoAssembler.create(domGlossary);
}
 
Example 13
Project: AvoinApotti   File: GlossaryAdminConfigurationImpl.java   View source code 6 votes vote down vote up
public ims.correspondence.vo.GlossaryProfileVo saveGlossaryProfile(ims.correspondence.vo.GlossaryProfileVo voGlossaryProfile) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if (voGlossaryProfile ==null)
		throw new CodingRuntimeException("Invalid argument: GlossaryProfileVo is null)");
		
	if (!voGlossaryProfile.isValidated())
		throw new DomainRuntimeException("GlossaryProfileVo has not been validated");
	
	DomainFactory factory = getDomainFactory();
	GlossaryProfile domGlossaryProfile = GlossaryProfileVoAssembler.extractGlossaryProfile(factory, voGlossaryProfile);

	try
	{
		factory.save(domGlossaryProfile);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("Profile already exists within the system for this user.", e);
	}

	return GlossaryProfileVoAssembler.create(domGlossaryProfile);
}
 
Example 14
Project: AvoinApotti   File: NoLetterRequiredAdminImpl.java   View source code 6 votes vote down vote up
public ims.correspondence.vo.NoLetterIsRequiredVo saveNoLetterIsRequired(ims.correspondence.vo.NoLetterIsRequiredVo voNoLetterIsRequired) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException 
{
	if (!voNoLetterIsRequired.isValidated())
	{
		throw new CodingRuntimeException("NoLetter is required record has not been validated");
	}
			
	DomainFactory factory = getDomainFactory();				
	NoLetterIsRequired domNLR =  NoLetterIsRequiredVoAssembler.extractNoLetterIsRequired(factory, voNoLetterIsRequired);
	try
	{
		factory.save(domNLR);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("No Letter required already exists within the system. Please try again to update.", e);
	}
	
	return NoLetterIsRequiredVoAssembler.create(domNLR);
}
 
Example 15
Project: AvoinApotti   File: StrengtheningProgramImpl.java   View source code 6 votes vote down vote up
/**
 * save StrenghteningProgram
 * @throws UniqueKeyViolationException 
 */
public ims.therapies.vo.StrengtheningProgramVo saveStrenghteningProgram(ims.therapies.vo.StrengtheningProgramVo voStrenghteningProgram) throws ims.domain.exceptions.StaleObjectException, UniqueKeyViolationException
{
	if (voStrenghteningProgram == null)
		throw new RuntimeException("Cannot save null StrengtheningProgramVo.");
	if (voStrenghteningProgram.isValidated() == false)
		throw new CodingRuntimeException("StrengtheningProgramVo is not validated");

	DomainFactory factory = getDomainFactory();
	if (voStrenghteningProgram.getID_StrengtheningProgram() == null)//Inserting a record
	{
		StrengtheningProgramVo voSP = getStrengthProgByClinicalContact(voStrenghteningProgram.getClinicalContact());
		if(voSP != null)
			throw new UniqueKeyViolationException("A record exists for this clinical contact, the screen will be refreshed");
	}
	StrengtheningProgram doStregtheningProgram = StrengtheningProgramVoAssembler.extractStrengtheningProgram(factory, voStrenghteningProgram);
	factory.save(doStregtheningProgram);
	return StrengtheningProgramVoAssembler.create(doStregtheningProgram);
}
 
Example 16
Project: AvoinApotti   File: DemographicsImpl.java   View source code 6 votes vote down vote up
/**
 * Get's a specific Patient
 * @throws  
 * @throws UniqueKeyViolationException 
 */
public ims.core.vo.Patient getPatient(PatientShort patient) throws StaleObjectException
{
	if (ConfigFlag.DOM.PATIENT_SEARCH_TYPE.getValue().equals("LOCAL"))
		return getLocalPatient(patient);
	else if (ConfigFlag.DOM.PATIENT_SEARCH_TYPE.getValue().equals("DTO"))
	{
		try
		{
			return getDTOPatient(patient);
		}
		catch (UniqueKeyViolationException e)
		{
			throw new DomainRuntimeException(e);
		}
	}

	return null;
}
 
Example 17
Project: AvoinApotti   File: DemographicsImpl.java   View source code 6 votes vote down vote up
public Patient savePatient(Patient patient, Boolean fromInterface) throws UniqueKeyViolationException, StaleObjectException, DomainInterfaceException, IndexOutOfBoundsException
{
	DomainFactory factory = getDomainFactory();
	factory.setDirtyCheck(true);
	if (!patient.isValidated())
	{
		throw new DomainRuntimeException("Patient VO has not been validated!");
	}
	patient.getName().setUppers();
	if (patient.getOtherNames() != null)
	{
		for (int i = 0; i < patient.getOtherNames().size(); i++)
		{
			patient.getOtherNames().get(i).setUppers();
		}
	}
	return this.savePatientRecord(factory, patient, 1, fromInterface);
}
 
Example 18
Project: AvoinApotti   File: Logic.java   View source code 6 votes vote down vote up
private void save(OrganisationVo voOrg, LocSiteVo voLocSite, LocMostVo voLoc) throws UniqueKeyViolationException, StaleObjectException 
{
	if (voOrg != null)
	{	
		domain.saveOrganisation(voOrg);
	}
	else if (voLocSite != null)
	{	
		//wdev-12855
		if(form.getLocalContext().getEditObject() instanceof LocSiteVo && ((LocSiteVo)form.getLocalContext().getEditObject()).getID_LocationIsNotNull() && voLocSite.getVersion_Location() != ((LocSiteVo)form.getLocalContext().getEditObject()).getVersion_Location())
			throw new StaleObjectException(null);
		
		domain.saveLocationSite(voLocSite);
	}
	else if (voLoc != null)
	{
		//wdev-12855
		if(form.getLocalContext().getEditObject() instanceof LocMostVo && ((LocMostVo)form.getLocalContext().getEditObject()).getID_LocationIsNotNull() && voLoc.getVersion_Location() != ((LocMostVo)form.getLocalContext().getEditObject()).getVersion_Location())
			throw new StaleObjectException(null);
		domain.saveLocation(voLoc);
	}
	form.getLocalContext().setSavingRootOrg(null);
}
 
Example 19
Project: AvoinApotti   File: AlertsImpl.java   View source code 6 votes vote down vote up
public PatientNoAlertInfoVo savePatientCoreClinicalData(PatientNoAlertInfoVo patientNoAlertInfo) throws StaleObjectException, UniqueKeyViolationException 
{
	if(!patientNoAlertInfo.isValidated())
	{
		throw new CodingRuntimeException("PatientNoAlertInfoVo Value Object Alert has not been validated");
	}

	DomainFactory factory = getDomainFactory();
	PatientNoAlertInfo doPatientNoAlertInfo = PatientNoAlertInfoVoAssembler.extractPatientNoAlertInfo(factory, patientNoAlertInfo);
		
	try
	{
		factory.save(doPatientNoAlertInfo);
	} 
	catch(UnqViolationUncheckedException e)
	{		
		PatientNoAlertInfo noAlertInfo = PatientNoAlertInfo.getPatientNoAlertInfoFromPatient(factory, patientNoAlertInfo.getPatient().getID_Patient());
		if (noAlertInfo != null && noAlertInfo.getId() != null && !(noAlertInfo.getId().equals(patientNoAlertInfo.getID_PatientNoAlertInfo())))
		{
			throw new UniqueKeyViolationException(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue(), e);					
		}

		throw (e);
	}
	return (PatientNoAlertInfoVoAssembler.create(doPatientNoAlertInfo));		
}
 
Example 20
Project: AvoinApotti   File: TrackingConfigurationImpl.java   View source code 6 votes vote down vote up
public TrackingConfigurationVo save(TrackingConfigurationVo trackingConfigToSave) throws StaleObjectException, UniqueKeyViolationException
{
	
	if (trackingConfigToSave == null )

		throw new CodingRuntimeException("Cannot save TrackingConfiguration if null or get TrackingConfiguration on null ID . ");
		
	if (!trackingConfigToSave.isValidated())
		throw new CodingRuntimeException("TrackingConfigurationVo not Validated");
	try
	{
		DomainFactory factory = getDomainFactory();
		TrackingConfiguration trackingConfig = TrackingConfigurationVoAssembler.extractTrackingConfiguration(factory,trackingConfigToSave);

		factory.save(trackingConfig);
		
		return TrackingConfigurationVoAssembler.create(trackingConfig);
	}
	catch (UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("This Configuration Already Exist!", e);
	}
	
}
 
Example 21
Project: AvoinApotti   File: TargetConfigurationImpl.java   View source code 6 votes vote down vote up
public TargetConfigurationVo save(TargetConfigurationVo record) throws StaleObjectException, UniqueKeyViolationException 
{	
	if(!record.isValidated())
		throw new CodingRuntimeException("Record not validated");
	
	if (record.getStatusIsNotNull() &&
			record.getStatus().equals(PreActiveActiveInactiveStatus.ACTIVE))
	{
		if (checkForUniq(record).size() > 0)
			throw new UniqueKeyViolationException("TargetName must be unique!");
	}
	
	DomainFactory factory = getDomainFactory();
	Target domainRecord = TargetConfigurationVoAssembler.extractTarget(factory, record);		
	
	domainRecord.setUpperName(domainRecord.getName());
	factory.save(domainRecord);
		
	return TargetConfigurationVoAssembler.create(domainRecord);
}
 
Example 22
Project: AvoinApotti   File: AlertsCcImpl.java   View source code 6 votes vote down vote up
public ims.core.vo.PatientNoAlertInfoForTriageVo savePatientNoAlertInfo(ims.core.vo.PatientNoAlertInfoForTriageVo patientNoAlertInfo) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if(patientNoAlertInfo == null)
		throw new CodingRuntimeException("Cannot save a null PatientNoAlertInfo.");
	
	if(!patientNoAlertInfo.isValidated())
		throw new CodingRuntimeException("PatientNoAlertInfo is not validated");
	
	DomainFactory factory = getDomainFactory();
	
	PatientNoAlertInfo doPatientNoAlertInfo = PatientNoAlertInfoForTriageVoAssembler.extractPatientNoAlertInfo(factory, patientNoAlertInfo);
	
	try
	{
		factory.save(doPatientNoAlertInfo);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
	}
	
	return PatientNoAlertInfoForTriageVoAssembler.create(doPatientNoAlertInfo);
}
 
Example 23
Project: AvoinApotti   File: SecurityLevelConfigImpl.java   View source code 6 votes vote down vote up
/**
* saveSecurityLevel
*/
public void saveSecurityLevel(ims.ocrr.vo.SecurityLevelConfigVo voSecurityLevel) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if (voSecurityLevel == null)
		throw new CodingRuntimeException("voSecurityLevel is null in method saveSecurityLevel");
	if (!voSecurityLevel.isValidated())
		throw new CodingRuntimeException("voSecurityLevel has not been validated in method saveSecurityLevel");
			
	try
	{
		getDomainFactory().save(SecurityLevelConfigVoAssembler.extractSecurityLevel(getDomainFactory(), voSecurityLevel));
	}
	catch (UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("A record with the same name already exists, Please Change.");
	}
}
 
Example 24
Project: AvoinApotti   File: TaxonomyLoaderHelper.java   View source code 6 votes vote down vote up
private OrgVo savePracticeVo(OrgVo vo) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	//WDEV-17409
	String[] err = vo.validate();
	if (err != null && err.length > 0) 
	{
		String concat = "";
		for (int i = 0; i < err.length; i++) 
		{
			concat = concat + " " + err[i] + " ";
		}
		throw new DomainRuntimeException(concat);
	} else 
	{
			return domainTaxonomy.savePracticeRecord(vo);
	}
}
 
Example 25
Project: AvoinApotti   File: DailyPatternandShiftsImpl.java   View source code 6 votes vote down vote up
/**
* save 
 * @throws UniqueKeyViolationException 
*/
public ims.clinicaladmin.vo.DailyPatternConfigVo save(ims.clinicaladmin.vo.DailyPatternConfigVo record) throws ims.domain.exceptions.StaleObjectException, UniqueKeyViolationException
{
	if(record == null)
		throw new DomainRuntimeException("Invalid record");
	if(!record.isValidated())
		throw new CodingRuntimeException("Record not validated");
	
	DomainFactory factory = getDomainFactory();
	DailyPattern domainRecord = DailyPatternConfigVoAssembler.extractDailyPattern(factory, record);		
	try
	{
		factory.save(domainRecord);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("A Daily Pattern record of this type already exists. Duplicates not allowed.", e);
	}
	
	return DailyPatternConfigVoAssembler.create(domainRecord);
}
 
Example 26
Project: AvoinApotti   File: SystemReviewConfigurationImpl.java   View source code 6 votes vote down vote up
public SystemReviewForPresentingProblemConfigVo save(SystemReviewForPresentingProblemConfigVo record)	throws StaleObjectException, UniqueKeyViolationException 
{
	if(	record == null)
		throw new DomainRuntimeException(" SystemReviewForPresentingProblemConfigVo has not be validated.");
	
	DomainFactory factory = getDomainFactory();	
	SystemReviewForPresentingProblemConfig doSystemReviewForPresentingProblemConfig = SystemReviewForPresentingProblemConfigVoAssembler.extractSystemReviewForPresentingProblemConfig(factory, record);
	
	try
	{
		factory.save(doSystemReviewForPresentingProblemConfig);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException();
	}
	
	return SystemReviewForPresentingProblemConfigVoAssembler.create(doSystemReviewForPresentingProblemConfig);
}
 
Example 27
Project: AvoinApotti   File: TumourCategoryGroupSitesImpl.java   View source code 6 votes vote down vote up
public TumourCategoryVo saveCategory(TumourCategoryVo record) throws StaleObjectException, UniqueKeyViolationException
{
	if (record == null)
		throw new DomainRuntimeException("Invalid record");

	if (!record.isValidated())
		throw new CodingRuntimeException("Record not validated");

	DomainFactory factory = getDomainFactory();
	TumourCategory domainRecord = TumourCategoryVoAssembler.extractTumourCategory(factory, record);

	try
	{
		factory.save(domainRecord);
	}
	catch (UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException(e);
	}

	return TumourCategoryVoAssembler.create(domainRecord);
}
 
Example 28
Project: AvoinApotti   File: M02VoMapper.java   View source code 6 votes vote down vote up
private OrganisationVo saveOrganisation(OrganisationVo orgVo) throws HL7Exception,StaleObjectException
	{
		String[] errors = orgVo.validate();
		if (errors != null)
		{
			throw new HL7Exception("Validation errors before save of GP Practice Org. " + VoMapper.toDisplayString(errors));				
		}			
		try
		{
			orgVo = orgLoc.saveOrganisation(orgVo);
		}
//		catch (StaleObjectException e)
//		{
//			LOG.error("GP Practice has been modified by another user/process - please try again");
//			throw new HL7Exception("LocationSite has been modified by another user/process - please try again", e);
//		}
		catch (UniqueKeyViolationException e)
		{
			LOG.error("UniqueKeyViolationException occurred saving GP Practice " + e.getMessage(), e);
			throw new HL7Exception("UniqueKeyViolationException occurred saveLocationSite " + e.getMessage(), e);
		}
		return orgVo;
	}
 
Example 29
Project: AvoinApotti   File: TumourCategoryGroupSitesImpl.java   View source code 6 votes vote down vote up
public TumourGroupVo saveGroup(TumourGroupVo voGroup, TumourCategoryVersionGroupsLiteVo version) throws StaleObjectException, UniqueKeyViolationException
{
	if (voGroup == null || version == null)
		throw new DomainRuntimeException("Invalid record to save");
	
	if (!voGroup.isValidated() || !version.isValidated())
		throw new DomainRuntimeException("Record to save not validated");
	
	TumourCategoryVersionGroups domVersion = (TumourCategoryVersionGroups) getDomainFactory().getDomainObject(version);
	TumourGroup domGroup = TumourGroupVoAssembler.extractTumourGroup(getDomainFactory(), voGroup);
	
	if (voGroup.getID_TumourGroupIsNotNull())
	{
		// Actually an edit - no need to save at version level
		getDomainFactory().save(domGroup);
		
		return TumourGroupVoAssembler.create(domGroup);
	}
	
	// A new group is created - we need to save the group at Version level
	domVersion.getGroups().add(domGroup);
	
	getDomainFactory().save(domVersion);

	return TumourGroupVoAssembler.create(domGroup);
}
 
Example 30
Project: AvoinApotti   File: TumourCategoryGroupSitesImpl.java   View source code 6 votes vote down vote up
public TumourSiteVo saveSite(TumourSiteVo record, TumourGroupListVo voGroup) throws StaleObjectException, UniqueKeyViolationException
{
	if (record == null || voGroup == null)
		throw new DomainRuntimeException("Invalid record to save");
	
	if (!record.isValidated() || !voGroup.isValidated())
		throw new DomainRuntimeException("Record to save not validated");
	
	TumourGroup domGroup = (TumourGroup) getDomainFactory().getDomainObject(voGroup);
	TumourSite domSite = TumourSiteVoAssembler.extractTumourSite(getDomainFactory(), record);
	
	if (record.getID_TumourSiteIsNotNull())
	{
		// Actually an edit - no need to save at group level
		getDomainFactory().save(domSite);
		
		return TumourSiteVoAssembler.create(domSite);
	}
	
	// A new site record is created - we need to save at group level
	domGroup.getSites().add(domSite);
	
	getDomainFactory().save(domGroup);

	return TumourSiteVoAssembler.create(domSite);
}
 
Example 31
Project: AvoinApotti   File: UserAssessmentNewImpl.java   View source code 6 votes vote down vote up
public UserAssessmentVo saveAssessment(UserAssessmentVo assessment)	throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	if(assessment.isValidated() == false)
		throw new DomainRuntimeException("UserAssessmentVo not validated");
	
	DomainFactory factory = getDomainFactory();
	UserAssessment obj = UserAssessmentVoAssembler.extractUserAssessment(factory, assessment);
	
	try
	{
		factory.save(obj);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("Already exists a question with this taxonomy code.", e);
	}
	
	return UserAssessmentVoAssembler.create(obj);
}
 
Example 32
Project: AvoinApotti   File: AttendanceKPIConfigurationImpl.java   View source code 6 votes vote down vote up
public ims.emergency.vo.AttendanceKPIConfigVo saveAttendanceKPIConfig(ims.emergency.vo.AttendanceKPIConfigVo record) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if (record == null)
		throw new CodingRuntimeException("Cannot save null AttendanceKPIConfigVo");

	DomainFactory factory = getDomainFactory();
			
	AttendanceKPIConfig doAttendanceKPIConfig = AttendanceKPIConfigVoAssembler.extractAttendanceKPIConfig(factory, record);

	try
	{
		factory.save(doAttendanceKPIConfig);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException();
	}

	return AttendanceKPIConfigVoAssembler.create(doAttendanceKPIConfig);
}
 
Example 33
Project: AvoinApotti   File: RACPCSummaryImpl.java   View source code 5 votes vote down vote up
public RACPCSummaryVo saveRACPCSummary(RACPCSummaryVo summary) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	if(summary == null)
		throw new CodingRuntimeException("Cannot save a null RACPCSummaryVo");
	
	if(!summary.isValidated())
		throw new CodingRuntimeException("RACPCSummaryVo is not validated");
	
	DomainFactory factory = getDomainFactory();
	RACPCSummary doSummary = RACPCSummaryVoAssembler.extractRACPCSummary(factory, summary);
	
	factory.save(doSummary);
	
	return RACPCSummaryVoAssembler.create(doSummary);
}
 
Example 34
Project: AvoinApotti   File: Logic.java   View source code 5 votes vote down vote up
/**
 * @param voOrg
 */
private boolean saveSupplier(OrgShortVo voOrg) 
{
	String[] arrErrors = null;
	
	if(voOrg != null)
		arrErrors = voOrg.validate();
	
	if(arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return false;
	}

	try {
			if(voOrg != null)
			{				
				form.getLocalContext().setSupplier(domain.saveOrganisationShort(voOrg));
			}
		}
	catch (StaleObjectException e) 
	{
		engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		open();
		return false;
	} 
	catch (UniqueKeyViolationException e1) 
	{
		engine.showMessage(e1.getMessage());
		return false;
	} 
	
	return true;
}
 
Example 35
Project: AvoinApotti   File: TumourDetailsImpl.java   View source code 5 votes vote down vote up
/**
 * Domain Interface function used to save Primary Tumour Details records
 * 
 * Will return the saved record
 */
public PrimaryTumourDetailsVo saveTumourDetails(PrimaryTumourDetailsVo tumourDetails, PrimaryTumourDetailsRefVo currentEditableRecord) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if(tumourDetails == null)
		throw new CodingRuntimeException("Invalid record");

	if(!tumourDetails.isValidated())
		throw new CodingRuntimeException("Record not validated");
	
	DomainFactory factory = getDomainFactory();

	// Set is current to false to current Primary Tumour Details record
	if (currentEditableRecord != null && currentEditableRecord.getID_PrimaryTumourDetailsIsNotNull()
			&& !currentEditableRecord.getID_PrimaryTumourDetails().equals(tumourDetails.getID_PrimaryTumourDetails()))
	{
		PrimaryTumourDetails currentEditableDomainObject = (PrimaryTumourDetails) getDomainFactory().getDomainObject(PrimaryTumourDetails.class, currentEditableRecord.getID_PrimaryTumourDetails());
		
		currentEditableDomainObject.setIsCurrent(Boolean.FALSE);
		
		factory.save(currentEditableDomainObject);
	}
		
	PrimaryTumourDetails domainRecord = PrimaryTumourDetailsVoAssembler.extractPrimaryTumourDetails(factory, tumourDetails);		
	
	factory.save(domainRecord);		
	
	return PrimaryTumourDetailsVoAssembler.create(domainRecord);
}
 
Example 36
Project: AvoinApotti   File: DischargeSummaryWardPacuImpl.java   View source code 5 votes vote down vote up
public DischargeSummaryPacuAndWardVo saveDischargeSummaryWardAndPacu(DischargeSummaryPacuAndWardVo dischargeSummary) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if (dischargeSummary == null)
		throw new CodingRuntimeException("Logical error - discharge summary is null in domain.save");
	
	if (!dischargeSummary.isValidated())
		throw new CodingRuntimeException("Logical error - Validate the Vo before saving");
	
	DomainFactory factory = getDomainFactory();
	DischargeSummaryPacuAndWard domDischargeSummary = DischargeSummaryPacuAndWardVoAssembler.extractDischargeSummaryPacuAndWard(factory, dischargeSummary);
	
	factory.save(domDischargeSummary);
	
	return DischargeSummaryPacuAndWardVoAssembler.create(domDischargeSummary);
}
 
Example 37
Project: AvoinApotti   File: Logic.java   View source code 5 votes vote down vote up
private void removeFunction()
{
	if (form.getLocalContext().getSelectedRecordIsNotNull() && form.getLocalContext().getSelectedRecordFunctionIsNotNull())
	{
		try
		{
			try
			{
				try
				{
					domain.removeServiceFunction(form.getLocalContext().getSelectedRecordFunction());
					updateServiceEntry(form.treService().getSelectedNode().getParent());
					form.treService().setValue(null);
				}
				catch (UniqueKeyViolationException de)
				{
					if (form.getLocalContext().getSelectedRecordFunction().getFunctionIsNotNull())
						engine.showMessage("Cannot remove " + ConfigFlag.UI.DISPLAY_NAME_FUNCTION.getValue(true) + " : " + (form.getLocalContext().getSelectedRecordFunction().getFunctionIsNotNull() ? form.getLocalContext().getSelectedRecordFunction().getFunction().toString() : "") + ". It is already used in a Location.");
					else
						engine.showMessage("Cannot remove this" + ConfigFlag.UI.DISPLAY_NAME_FUNCTION.getValue(true) + " as it is already used in a location.");
					setScreenViewMode();
				}
			}
			catch (StaleObjectException se)
			{
				engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
				open();
			}
		}
		catch (ForeignKeyViolationException e)
		{
			engine.showMessage(e.getMessage());
			setScreenViewMode();
		}
	}
}
 
Example 38
Project: AvoinApotti   File: ClinicalCodingImpl.java   View source code 5 votes vote down vote up
public ProblemConfigVo saveConfigVo(ProblemConfigVo voProblemConfig) throws StaleObjectException, UniqueKeyViolationException 
{
	if (!voProblemConfig.isValidated())
	{
		throw new DomainRuntimeException("This ProblemConfigVo has not be validated.");
	}
	
	DomainFactory factory = getDomainFactory();			
	ClinicalProblem domProblem = ProblemConfigVoAssembler.extractClinicalProblem(factory, voProblemConfig);
	
	domProblem.setKeywords(Keywords.setupKeyWords(domProblem.getKeywords(), domProblem.getPCName()));
	try
	{
		factory.save(domProblem);
	}
	catch(UnqViolationUncheckedException e)
	{
		//check which constraint was violated (name/taxononmy map)

		//name
		ClinicalProblem prob = ClinicalProblem.getClinicalProblemFromPCName(factory, voProblemConfig.getPCName());
		if (prob != null && prob.getId() != null && !(prob.getId().equals(voProblemConfig.getID_ClinicalProblem())))
		{
			throw new UniqueKeyViolationException("Problem record called \"" + voProblemConfig.getPCName() + "\" already exists. Duplicates not allowed.", e);					
		}
		
		//taxonomy map
		String dupMessage = Keywords.checkDuplicateTaxonomy(factory, domProblem, voProblemConfig.getTaxonomyMap(), "getPCName");
		if(dupMessage != null)
			throw new UniqueKeyViolationException(dupMessage);
		
		throw (e);
	}
	return ProblemConfigVoAssembler.create(domProblem);
}
 
Example 39
Project: AvoinApotti   File: SecurityTokenAdminImpl.java   View source code 5 votes vote down vote up
public String getSecurityToken(String username, String password) throws DomainInterfaceException, StaleObjectException,	UniqueKeyViolationException 
{
	if(username == null || username.length() == 0)
		throw new DomainInterfaceException("Can not generate security token for empty username.");
	
	if(password == null || password.length() == 0)
		throw new DomainInterfaceException("Can not generate security token for empty password.");
	
	DomainFactory factory = getDomainFactory();
	
	SecurityTokenVo st= new SecurityTokenVo();
	SecurityParamVoCollection params = new SecurityParamVoCollection();
	
	SecurityParamVo sp1 = new SecurityParamVo();
	sp1.setItem("username");
	sp1.setValue(username);
	params.add(sp1);
	
	SecurityParamVo sp2 = new SecurityParamVo();
	sp2.setItem("password");
	sp2.setValue(password);
	params.add(sp2);
	
	st.setParams(params);
	
	String securityToken = UUID.randomUUID().toString();
	st.setTokenID(securityToken);
	st.setExpirationTimeStamp(new DateTime().addMinutes(10));
	
	SecurityToken stDom = SecurityTokenVoAssembler.extractSecurityToken(factory, st);
	
	factory.save(stDom);
	
	return securityToken;
}
 
Example 40
Project: AvoinApotti   File: ICPConfigImpl.java   View source code 5 votes vote down vote up
/**
 * Function used to add an ICP Phase to an ICP Stage
 */
@SuppressWarnings("unchecked")
public ICPPhaseVo addPhase(ICPPhaseVo phase, ICPStageShortVo stage) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Check for parameters
	if (stage == null)
		throw new DomainRuntimeException("Logical error - Can not add an ICP Phase to a null ICP Stage");

	if (phase == null)
		throw new DomainRuntimeException("Logical error - Can not add a null ICP Phase to an ICP Stage");

	// Check VO for validation
	if (!stage.isValidated() || !phase.isValidated())
		throw new DomainRuntimeException("Logical error - ICP Phase Vo and ICP Stage Vo must be validated before save");

	// Get domain factory
	DomainFactory factory = getDomainFactory();

	// Extract ICP Phase domain object
	ICPPhase domainICPPhase = ICPPhaseVoAssembler.extractICPPhase(factory, phase);

	// Extract ICP Stage domain object
	ICPStage domainICPStage = ICPStageShortVoAssembler.extractICPStage(factory, stage);

	domainICPStage.getPhases().add(domainICPPhase);

	// Save ICP domain object
	factory.save(domainICPStage);

	// Return the saved phase
	return ICPPhaseVoAssembler.create(domainICPPhase);
}