Java Code Examples for ims.domain.exceptions.ForeignKeyViolationException

The following are top voted examples for showing how to use ims.domain.exceptions.ForeignKeyViolationException. 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: HospitalAtNightCutOffPointsConfigImpl.java   View source code 6 votes vote down vote up
public void deleteHospitalConfig(HospitalAtNightCutOffPointsConfigVo hospitalConfig) throws ForeignKeyViolationException
{
	if (hospitalConfig == null)
		throw new CodingRuntimeException("Cannot delete null hospitalConfig");

	try
	{
		DomainFactory factory = getDomainFactory();
		HospitalAtNightCutOverPointsConfig domainHospital = HospitalAtNightCutOffPointsConfigVoAssembler.extractHospitalAtNightCutOverPointsConfig(factory, hospitalConfig);

		factory.delete(domainHospital);

	}
	catch (ForeignKeyViolationException e)
	{
		throw new ForeignKeyViolationException("Hospital configuration is used in the system.", e);
	}

}
 
Example 2
Project: AvoinApotti   File: GoalPlanningImpl.java   View source code 6 votes vote down vote up
/**
 *  Function used to save a PatientGoalTarget to database
 */
public PatientGoalTargetVo savePatientGoalTarget(PatientGoalTargetVo patientGoalTarget) throws StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	// Check if PatientGoalTargetVo was validated
	if (patientGoalTarget == null || !patientGoalTarget.isValidated())
	{
		throw new DomainRuntimeException("Logical error - PatientGoalTargetVo has not been validated");
	}
	
	// Extract a domain object from PatientGoalTargetVo
	DomainFactory factory = getDomainFactory();
	PatientGoalTarget doPatientGoalTarget = PatientGoalTargetVoAssembler.extractPatientGoalTarget(factory, patientGoalTarget);
	
	// Save to database
	factory.save(doPatientGoalTarget);
	
	// Return saved PatientGoalTargetVo (with ID from database)
	return PatientGoalTargetVoAssembler.create(doPatientGoalTarget);
}
 
Example 3
Project: AvoinApotti   File: UserProfileImpl.java   View source code 6 votes vote down vote up
public UserAccessVo saveUserAccess(UserAccessVo voUserAccess) throws StaleObjectException, ForeignKeyViolationException,UniqueKeyViolationException 
{
	if (!voUserAccess.isValidated())			
			throw new DomainRuntimeException("UserAccessVo has not been validated.");

	DomainFactory factory = getDomainFactory();		
	UserAccess domUserAccess = UserAccessVoAssembler.extractUserAccess(factory, voUserAccess);
	try
	{
		factory.save(domUserAccess);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("User Profie already exists within the system for this user.", e);
	}
	
	return UserAccessVoAssembler.create(domUserAccess);		
}
 
Example 4
Project: AvoinApotti   File: DocumentCategoryConfigImpl.java   View source code 6 votes vote down vote up
public DocumentCategoryConfigShortVo save(DocumentCategoryConfigShortVo record) throws StaleObjectException, ForeignKeyViolationException
{
	if (!record.isValidated())
		throw new DomainRuntimeException("Unable to save a record that is not validated");

	DomainFactory factory = getDomainFactory();
	if (!record.getID_DocumentCategoryConfigIsNotNull())
	{
		String count = "select count(dcc.id) from DocumentCategoryConfig as dcc left join dcc.template as tem	where (tem.id = :templateId)";
		long configs = factory.countWithHQL(count, new String[] { "templateId" }, new Object[]{record.getTemplate().getID_TemplateBo()});

		if (configs > 0)
		{
			throw new StaleObjectException(null);
		}
	}

	DocumentCategoryConfig dccDO = DocumentCategoryConfigShortVoAssembler.extractDocumentCategoryConfig(factory, record);
	factory.save(dccDO);

	return DocumentCategoryConfigShortVoAssembler.create(dccDO);
}
 
Example 5
Project: AvoinApotti   File: UserProfileConfigurationImpl.java   View source code 6 votes vote down vote up
public UserAccessVo saveUserAccess(UserAccessVo voUserAccess) throws StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if (! voUserAccess.isValidated())
		throw new DomainRuntimeException("UserAccessVo has not been validated");
	
	DomainFactory factory = getDomainFactory();
	
	UserAccess domUserAccess = UserAccessVoAssembler.extractUserAccess(factory, voUserAccess);
	
	try
	{
		factory.save(domUserAccess);
	}
	catch (UnqViolationUncheckedException exception)
	{
		throw new UniqueKeyViolationException("User Profile already exists within the system for this user.", exception);
	}
	
	return UserAccessVoAssembler.create(domUserAccess);
}
 
Example 6
Project: AvoinApotti   File: GlossaryAdminImpl.java   View source code 6 votes vote down vote up
public void deleteGlossary(GlossaryRefVo voGlossaryRef) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException 
{
	DomainFactory factory = getDomainFactory();
	
	String hql1 = " from Glossary g " +
	" where g.id = " +  voGlossaryRef.getID_Glossary();

	try
	{
		factory.delete(hql1);
	}
	catch (ForeignKeyViolationException e)
	{
		throw new ForeignKeyViolationException("There are data items in the system referencing this item - delete access denied", e);
	}
}
 
Example 7
Project: AvoinApotti   File: GlossaryAdminConfigurationImpl.java   View source code 6 votes vote down vote up
public void deleteGlossary(ims.correspondence.configuration.vo.GlossaryRefVo voGlossaryRef) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException
{
	DomainFactory factory = getDomainFactory();
	
	String hql1 = " from Glossary g " +
	" where g.id = " +  voGlossaryRef.getID_Glossary();

	try
	{
		factory.delete(hql1);
	}
	catch (ForeignKeyViolationException e)
	{
		throw new ForeignKeyViolationException("There are data items in the system referencing this item - delete access denied", e);
	}
}
 
Example 8
Project: AvoinApotti   File: TemplateAssociationsConfigurationImpl.java   View source code 6 votes vote down vote up
public TemplateAssociationsVo saveTemplateAssociations(TemplateAssociationsVo templateAssociation) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if (! templateAssociation.isValidated())
		throw new DomainRuntimeException("TempalteAssociationsVo has not been validated");
	
	DomainFactory factory = getDomainFactory();
	
	TemplateAssociations domTemplateAssociations = TemplateAssociationsVoAssembler.extractTemplateAssociations(factory, templateAssociation);

	try
	{
		factory.save(domTemplateAssociations);
	}
	catch (UnqViolationUncheckedException exception)
	{
		throw new UniqueKeyViolationException("Template Association already exists for this template.", exception);
	}

	return TemplateAssociationsVoAssembler.create(domTemplateAssociations);
}
 
Example 9
Project: AvoinApotti   File: CorrespondenceHeadersAdminConfigurationImpl.java   View source code 6 votes vote down vote up
public void saveTemplateCategories(TemplateCategoryVoCollection templateCollection,	TemplateCategoryVoCollection deleteCollection) throws StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException 
{
	if (templateCollection == null)
		throw new CodingRuntimeException("Invalid Argument: Template Category Collection is null");
	if (!templateCollection.isValidated())
		throw new DomainRuntimeException("TemplateCategoryVoCollection not validated.");
	
	DomainFactory factory = getDomainFactory();
	
	for(int i=0; i<templateCollection.size(); i++)
	{
		TemplateCategory domTemplCategory = TemplateCategoryVoAssembler.extractTemplateCategory(factory, templateCollection.get(i));
		factory.save(domTemplCategory);
	}
	
	if(deleteCollection != null && deleteCollection.size() > 0)
	{
		for(int i=0; i<deleteCollection.size(); i++)
		{
			TemplateCategory delTemplCategory = TemplateCategoryVoAssembler.extractTemplateCategory(factory, deleteCollection.get(i));
			factory.delete(delTemplCategory);
		}
	}
}
 
Example 10
Project: AvoinApotti   File: ResultCommentsDialogImpl.java   View source code 6 votes vote down vote up
private void removeCommentFromOrderInvestigation(OcsPathRadResultVo result, ResultCommentsVo comment) throws StaleObjectException, ForeignKeyViolationException
{
	if (result == null || !result.getOrderInvestigationIsNotNull() || !result.getOrderInvestigation().getID_OrderInvestigationIsNotNull())
		throw new DomainRuntimeException("Can not remove comment from null parent.");
	
	if (comment == null || !comment.getID_ResultConclusionAndActionCommentIsNotNull())
		throw new DomainRuntimeException("Can not remove unsaved comment.");
	
	DomainFactory factory = getDomainFactory();
	
	// Extract comment domain object
	ResultConclusionAndActionComment domComment = (ResultConclusionAndActionComment) factory.getDomainObject(ResultConclusionAndActionComment.class, comment.getID_ResultConclusionAndActionComment());
	
	// Check for stale comment (deleted or edited)
	if (domComment == null || domComment.getVersion() > comment.getVersion_ResultConclusionAndActionComment())
		throw new StaleObjectException(domComment);
	
	OrderInvestigation domOrderInv = (OrderInvestigation) factory.getDomainObject(OrderInvestigation.class, result.getOrderInvestigation().getID_OrderInvestigation());
	
	// Remove comment from order investigation comments
	domOrderInv.getResultConclusionComments().remove(domComment);
	factory.delete(domComment);
	factory.save(domOrderInv);
	
	return;
}
 
Example 11
Project: AvoinApotti   File: PatientCorrespondenceTemplatesImpl.java   View source code 6 votes vote down vote up
public void deleteDocument(PatientDocumentRefVo patRef)
{
	if (patRef == null || !patRef.getID_PatientDocumentIsNotNull())
	{
		throw new DomainRuntimeException("Invalid patient document provided in delete");
	}
	DomainObject dom = getDomainFactory().getDomainObject(PatientDocument.class, patRef.getID_PatientDocument());
	try
	{
		getDomainFactory().delete(dom);
	}
	catch (ForeignKeyViolationException e)
	{
		//How to handle this ????
		e.printStackTrace();
	}	
}
 
Example 12
Project: AvoinApotti   File: DocumentWorklistImpl.java   View source code 6 votes vote down vote up
public void deletePatientDocument(PatientDocumentVo patDoc) throws ForeignKeyViolationException, StaleObjectException
{
	
	PatientDocument patDO = PatientDocumentVoAssembler.extractPatientDocument(getDomainFactory(), patDoc);
	if (patDO == null )
		throw new StaleObjectException(patDO);
	
	long count  = getDomainFactory().countWithHQL("select count(patDoc.id) " +
			"from PatientDocument as patDoc where " +
			"(patDoc.id = :patDocId and patDoc.version=:patVersion)"
			,new String[]{"patDocId","patVersion"},
			new Object[]{patDoc.getID_PatientDocument(),patDoc.getVersion_PatientDocument()});
	
	if (count == 0)
		throw new StaleObjectException(patDO);
	
	//getDomainFactory().delete(patDO);
	patDO.setIsRIE(true);//WDEV-15417
	getDomainFactory().save(patDO);//WDEV-15417
}
 
Example 13
Project: AvoinApotti   File: ServiceImpl.java   View source code 6 votes vote down vote up
public void removeServiceFunction(ims.core.vo.ServiceFunctionVo voServiceFunction) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException, ims.domain.exceptions.UniqueKeyViolationException
{
	DomainFactory factory = getDomainFactory();

	ServiceFunction doServiceFunction = ServiceFunctionVoAssembler.extractServiceFunction(factory, voServiceFunction);
	try
	{
		factory.delete(doServiceFunction);
	}
	catch (DomainRuntimeException e) // SN: catching
										// DomainRuntimeException here as
										// this is what Hib is returning
										// with e.getCause() =
										// ConstrainViolationException
	{
		throw new UniqueKeyViolationException(e.getMessage());
	}
}
 
Example 14
Project: AvoinApotti   File: ReferralStatusListImpl.java   View source code 6 votes vote down vote up
public CatsReferralWizardVo resetProviderCancellation(CatsReferralWizardVo catsReferral, ProviderCancellationVo provCancellationVo) throws StaleObjectException, ForeignKeyViolationException 
{
	if(catsReferral == null)
		throw new CodingRuntimeException("Invalid CatsReferralWizardVo");
	if(!catsReferral.isValidated())
		throw new CodingRuntimeException("CatsReferralWizardVo not validated");
	
	if(provCancellationVo == null)
		throw new CodingRuntimeException("Invalid ProviderCancellationVo");
	if(!provCancellationVo.isValidated())
		throw new CodingRuntimeException("ProviderCancellationVo not validated");
	
	DomainFactory factory = getDomainFactory();
	
	CatsReferral doCats = CatsReferralWizardVoAssembler.extractCatsReferral(factory, catsReferral);		
	factory.save(doCats);
	
	ProviderCancellation domainObject = ProviderCancellationVoAssembler.extractProviderCancellation(factory, provCancellationVo);
	factory.delete(domainObject);


	return CatsReferralWizardVoAssembler.create(doCats);
}
 
Example 15
Project: AvoinApotti   File: ProcedureListImpl.java   View source code 6 votes vote down vote up
public Boolean updateServiceActivityExportRecords(ProcedureVo procVo) throws StaleObjectException, ForeignKeyViolationException
{
	DomainFactory factory = getDomainFactory();

	ServiceActivityExportVoCollection collSERACT = ServiceActivityExportVoAssembler.
		createServiceActivityExportVoCollectionFromServiceActivityExport(factory.find("from ServiceActivityExport sax where sax.serviceActivity in (select sa.id from ServiceActivity sa where sa.activity.id = :actID )", new String[]{"actID"}, new Object[]{procVo.getActivity().getID_Activity()}));
	
	for (int i = 0 ; i < collSERACT.size() ; i++)
	{
		ServiceActivityExport doSerActExport = ServiceActivityExportVoAssembler.extractServiceActivityExport(factory, collSERACT.get(i));

		doSerActExport.setReadyForExport(true);
//		doSerActExport.setDateLastExported(null);
		
		factory.save(doSerActExport);
	}
	
	return true;

}
 
Example 16
Project: AvoinApotti   File: TumourHistologyConfigImpl.java   View source code 6 votes vote down vote up
/**
* Saves a TumourHistology record to database
*/
public TumourHistologyVo saveHistology(TumourHistologyVo histology) throws StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Check for value to save
	if (histology == null)
		throw new DomainRuntimeException("Domain Error - Can not save a null histology record");
	
	// Check for validated record
	if (!histology.isValidated())
		throw new DomainRuntimeException("Domain Error - Histology record must be validated before save");
	
	// Get domain object
	TumourHistology tumourHistology = TumourHistologyVoAssembler.extractTumourHistology(getDomainFactory(), histology);
	
	// Attempt save
	getDomainFactory().save(tumourHistology);
	
	return TumourHistologyVoAssembler.create(tumourHistology);
}
 
Example 17
Project: AvoinApotti   File: LeadConsultantForSpecialtyConfigImpl.java   View source code 6 votes vote down vote up
public void removeLeadCons(LeadConsultantForSpecialtyConfigVo leadCons) throws ForeignKeyViolationException
{
	if (leadCons == null)
		throw new CodingRuntimeException("Cannot remove LeadConsultant if null . ");
	
	try
	{
		DomainFactory factory = getDomainFactory();
		SpecialtyLeadConsultant domainLeadCons = LeadConsultantForSpecialtyConfigVoAssembler.extractSpecialtyLeadConsultant(factory, leadCons);			
		factory.delete(domainLeadCons);
	}
	catch (ForeignKeyViolationException e)
	{
		throw new ForeignKeyViolationException("This Configuration is in use!", e);
	}
}
 
Example 18
Project: AvoinApotti   File: SelectTumourHistologyImpl.java   View source code 6 votes vote down vote up
/**
 * Function used to commit a TumourHistologyVo records to database
 */
public TumourHistologyVo save(TumourHistologyVo histology) throws StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Check for something to save
	if (histology == null)
		throw new DomainRuntimeException("ERROR - Can not save null histology");
	// Check for validation
	if (!histology.isValidated())
		throw new DomainRuntimeException("ERROR - Can not save VO not validated");
	
	// Build DOM Object
	TumourHistology domHistology = TumourHistologyVoAssembler.extractTumourHistology(getDomainFactory(), histology);
	
	// Attempt save
	getDomainFactory().save(domHistology);
	
	return TumourHistologyVoAssembler.create(domHistology);
}
 
Example 19
Project: AvoinApotti   File: ICPConfigImpl.java   View source code 6 votes vote down vote up
/**
 * Function used to save provided ICP Stage to database
 */
public ICPStageVo saveICPStage(ICPStageVo icpStage) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Check for parameter
	if (icpStage == null)
		throw new DomainRuntimeException("Logical error - Can not save null ICP Stage");

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

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

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

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

	// Returned saved domain object
	return ICPStageVoAssembler.create(domainICPStage);
}
 
Example 20
Project: AvoinApotti   File: ICPConfigImpl.java   View source code 6 votes vote down vote up
/**
 * Function used to save provided ICP Phase to database
 */
public ICPPhaseVo saveICPPhase(ICPPhaseVo icpPhase) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Check for parameter
	if (icpPhase == null)
		throw new DomainRuntimeException("Logical error - Can not save null ICP Phase");

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

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

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

	// Save domain object
	factory.save(domainICPPhase);

	// Returned saved domain object
	return ICPPhaseVoAssembler.create(domainICPPhase);
}
 
Example 21
Project: AvoinApotti   File: ICPConfigImpl.java   View source code 6 votes vote down vote up
/**
 * Function used to save provided ICP Action to database
 */
public ICPActionShortVo saveICPAction(ICPActionShortVo icpAction) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Check for parameter
	if (icpAction == null)
		throw new DomainRuntimeException("Logical error - Can not save null ICP Action");

	// Check VO for validation
	if (!icpAction.isValidated())
		throw new DomainRuntimeException("Logical error - ICP Action Vo must be validated before save");

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

	// Extract ICP Action domain object
	ICPAction domainICPAction = ICPActionShortVoAssembler.extractICPAction(factory, icpAction);

	// Save domain object
	factory.save(domainICPAction);

	// Returned saved domain object
	return ICPActionShortVoAssembler.create(domainICPAction);
}
 
Example 22
Project: AvoinApotti   File: ICPConfigImpl.java   View source code 6 votes vote down vote up
/**
 * Function used to save two ICP Stages - used for moving up or down a stage
 */
public ICPStageLiteVo save(ICPStageLiteVo stage1, ICPStageLiteVo stage2) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Check for parameters
	if (stage1 == null || stage2 == null)
		return stage1;

	// Check if they are validated
	if (!stage1.isValidated() || !stage2.isValidated())
		throw new DomainRuntimeException("Stages must be validated");

	// Get factory
	DomainFactory factory = getDomainFactory();

	// Extract ICP Stages domain objects
	ICPStage domainICPStage1 = ICPStageLiteVoAssembler.extractICPStage(factory, stage1);
	ICPStage domainICPStage2 = ICPStageLiteVoAssembler.extractICPStage(factory, stage2);

	// Save ICP Stage domain objects
	factory.save(domainICPStage1);
	factory.save(domainICPStage2);

	// Return the saved stage
	return ICPStageLiteVoAssembler.create(domainICPStage1);
}
 
Example 23
Project: AvoinApotti   File: ICPConfigImpl.java   View source code 6 votes vote down vote up
/**
 * Function used to save two ICP Phases - used for moving up or down a stage
 */
public ICPPhaseLiteVo save(ICPPhaseLiteVo phase1, ICPPhaseLiteVo phase2) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Check for parameters
	if (phase1 == null || phase2 == null)
		return phase1;

	// Check if they are validated
	if (!phase1.isValidated() || !phase2.isValidated())
		throw new DomainRuntimeException("Phases must be validated");

	// Get factory
	DomainFactory factory = getDomainFactory();

	// Extract ICP Phases domain objects
	ICPPhase domainICPPhase1 = ICPPhaseLiteVoAssembler.extractICPPhase(factory, phase1);
	ICPPhase domainICPPhase2 = ICPPhaseLiteVoAssembler.extractICPPhase(factory, phase2);

	// Save ICP Phase domain objects
	factory.save(domainICPPhase1);
	factory.save(domainICPPhase2);

	// Return the saved phase
	return ICPPhaseLiteVoAssembler.create(domainICPPhase1);
}
 
Example 24
Project: AvoinApotti   File: ICPConfigImpl.java   View source code 6 votes vote down vote up
/**
 * Function used to generally inactivate an item It will call specific
 * functions to inactivate based on the type of the item provided
 */
public Object inactivateItem(Object item) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Get domain factory
	DomainFactory factory = getDomainFactory();

	if (item instanceof ICPRefVo)
	{
		return inactivateICP((ICP) factory.getDomainObject(ICP.class, ((ICPRefVo) item).getID_ICP()));
	}

	if (item instanceof ICPStageRefVo)
		return inactivateICPStage((ICPStage) factory.getDomainObject(ICPStage.class, ((ICPStageRefVo) item).getID_ICPStage()));

	if (item instanceof ICPPhaseRefVo)
		return inactivateICPPhase((ICPPhase) factory.getDomainObject(ICPPhase.class, ((ICPPhaseRefVo) item).getID_ICPPhase()));

	if (item instanceof ICPActionRefVo)
		return inactivateICPAction((ICPAction) factory.getDomainObject(ICPAction.class, ((ICPActionRefVo) item).getID_ICPAction()));

	return null;
}
 
Example 25
Project: AvoinApotti   File: FunctionalTransfersImpl.java   View source code 6 votes vote down vote up
/**
 *	Domain Interface function used to save a Functional Transfer
 */
public FunctionalTransfersVo saveFunctionalTransfers(FunctionalTransfersVo functionalTransfers) throws StaleObjectException, UniqueKeyViolationException, ForeignKeyViolationException 
{
	// Ensure the value object has been validated
	if (!functionalTransfers.isValidated())
		throw new DomainRuntimeException("FunctionalTransfers record has not been validated");

	// Creating a new record
	if (!functionalTransfers.getID_FunctionalTransfersIsNotNull())
	{
		if (existsRecord(functionalTransfers.getClinicalContact()))
			throw new ForeignKeyViolationException("A Functional Transfer record already exists for this Clinical Contact");
	}
		
	DomainFactory factory = getDomainFactory();
	FunctionalTransfers domFunctionalTransfers = FunctionalTransfersVoAssembler.extractFunctionalTransfers(factory, functionalTransfers);

	factory.save(domFunctionalTransfers);

	return FunctionalTransfersVoAssembler.create(domFunctionalTransfers);
}
 
Example 26
Project: AvoinApotti   File: ICPConfigImpl.java   View source code 6 votes vote down vote up
/**
 * Function used to inactivate an ICP Action
 */
public ICPActionShortVo inactivateICPAction(ICPAction icpAction) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	final int INACTIVE_STATUS = -618;

	// Check parameters
	if (icpAction == null)
		return null;

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

	// Retrieve ICP Action and modify the status
	icpAction.setStatus(factory.getLookupInstance(INACTIVE_STATUS));

	// Save ICP Action - We need to save, the function might be called by
	// itself
	factory.save(icpAction);

	return ICPActionShortVoAssembler.create(icpAction);
}
 
Example 27
Project: AvoinApotti   File: PatientICPActionLinkedDetailsComponentImpl.java   View source code 6 votes vote down vote up
public PatientAssessmentVo savePatientAssessment(PatientAssessmentVo patientAssessment) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	// Check for a PatientAssessment and if it is validated
	if (patientAssessment == null)
		throw new DomainInterfaceException("PatientAssessment can not be null");
	
	if (!patientAssessment.isValidated())
		throw new DomainInterfaceException("PatientAssessment must be validated");
	
	// Extract domain object
	PatientAssessment domPatientAssessment = PatientAssessmentVoAssembler.extractPatientAssessment(getDomainFactory(), patientAssessment);
	
	// Attempt save on the domain object
	getDomainFactory().save(domPatientAssessment);
	
	// Return saved PatientAssessment
	return PatientAssessmentVoAssembler.create(domPatientAssessment);
}
 
Example 28
Project: AvoinApotti   File: PatientICPActionLinkedDetailsComponentImpl.java   View source code 6 votes vote down vote up
public PatientAssessmentVo savePatientGraphicalAssessment(PatientAssessmentVo patientGraphicalAssessment) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	// Check for a PatientGraphicAssessment and if it is validated
	if (patientGraphicalAssessment == null)
		throw new DomainInterfaceException("PatientAssessment can not be null");
	
	if (!patientGraphicalAssessment.isValidated())
		throw new DomainInterfaceException("PatientAssessment must be validated");
	
	// Extract domain object
	PatientAssessment domPatientAssessment = PatientAssessmentVoAssembler.extractPatientAssessment(getDomainFactory(), patientGraphicalAssessment);
	
	// Attempt save on the domain object
	getDomainFactory().save(domPatientAssessment);
	
	// Return saved PatientAssessment
	return PatientAssessmentVoAssembler.create(domPatientAssessment);
}
 
Example 29
Project: AvoinApotti   File: ProfilesImpl.java   View source code 6 votes vote down vote up
private void saveProfileTemplates(DomainFactory factory, Sch_Profile domProfile, ProfileTemplateVoCollection templates) throws DomainRuntimeException, StaleObjectException
{
	try
	{
		factory.delete("from ProfileTemplate pt where pt.profile.id = '" + domProfile.getId() + "'" );
	}
	catch (ForeignKeyViolationException e)
	{
		throw new DomainRuntimeException("DomainException occurred saving profile - " + e.getMessage(), e);
	}
	
	if(templates != null)
	{
		for(int i=0; i<templates.size(); i++)
		{
			templates.get(i).setID_ProfileTemplate(null);
			ProfileTemplate doProfTemplate = ProfileTemplateVoAssembler.extractProfileTemplate(factory, templates.get(i));
			doProfTemplate.setProfile(domProfile);
			factory.save(doProfTemplate);
		}
	}
}
 
Example 30
Project: AvoinApotti   File: PrescriptionComponentImpl.java   View source code 6 votes vote down vote up
public void removePrescription(PrescriptionsVo selectedPrescription) throws StaleObjectException, ForeignKeyViolationException
{
	if (selectedPrescription == null)
		throw new CodingRuntimeException("Cannot delete null Prescription");

	
	DomainFactory factory = getDomainFactory();
	Prescription domainPrescription = PrescriptionsVoAssembler.extractPrescription(factory, selectedPrescription);

		try
		{
			factory.delete(domainPrescription);
		}
		catch (ForeignKeyViolationException e)
		{
			throw new ForeignKeyViolationException("Prescription is used in the system.", e);
		}
	
}
 
Example 31
Project: AvoinApotti   File: Logic.java   View source code 6 votes vote down vote up
private String getGpListMessage(OrganisationWithSitesVo voOrgWithSites, ForeignKeyViolationException excp)
{
	StringBuffer message = new StringBuffer();
	String[] gps = domain.listGps(voOrgWithSites);
	if(gps != null && gps.length > 0)
	{
		message.append("Cannot delete '" + voOrgWithSites.getName() + "' as it is currently associated with");
		message.append(" the following GPs:");
		for (int i = 0; i < gps.length; i++)
		{
			message.append(System.getProperty("line.separator"));
			message.append(gps[i]);
		}
	}
	else
	{
		message.append(excp.getMessage());
	}
	
	return message.toString();
}
 
Example 32
Project: AvoinApotti   File: Logic.java   View source code 6 votes vote down vote up
private String getGpListMessageLoc(LocSiteVo locVo, ForeignKeyViolationException excp)
{
	StringBuffer message = new StringBuffer();
	String[] gps = domain.listPatients(locVo);
	if(gps != null)
	{
		message.append("Cannot delete '" + locVo.getName() + "' as it is currently associated with");
		message.append(" " +gps.length + " Patients");
		/*for (int i = 0; i < gps.length; i++)
		{
			message.append(System.getProperty("line.separator"));
			message.append(gps[i]);
		}*/
	}
	else
	{
		message.append(excp.getMessage());
	}
	
	return message.toString();
}
 
Example 33
Project: AvoinApotti   File: Logic.java   View source code 6 votes vote down vote up
private boolean removeSurgery()
{
	LocSiteVo locVo = form.customControlPracticeAdmin().getSelectedSurgery();
	if(locVo == null)
		return false;
	try
	{
		setPracticeToContext(domain.deleteLocSite(locVo));
		form.getLocalContext().setSurgery(null);
		form.customControlPracticeAdmin().removeSurgeryFromGrid(locVo);
		if(canUseSurgery())
			open();
	}
	catch (ForeignKeyViolationException e)
	{
		engine.showMessage(getGpListMessageLoc(locVo,e)); //wdev-11819
		return false;
	}
	
	return true;
}
 
Example 34
Project: AvoinApotti   File: Logic.java   View source code 6 votes vote down vote up
private void unassignTemplate()
{
	TreeNode node = form.treBOList().getSelectedNode();
	
	if(node != null && node.getParent() != null)
		form.getLocalContext().setLastNode((String) node.getParent().getValue());
	
	ReportTemplateBoRefVo item = (ReportTemplateBoRefVo) form.treBOList().getValue();
	
	try
	{
		domain.removeLink(item);
		open();
	}
	catch (ForeignKeyViolationException e)
	{
		engine.showMessage("Error unassigning the template: " + e.toString());
		return;
	}
}
 
Example 35
Project: AvoinApotti   File: ReferralServicesImpl.java   View source code 6 votes vote down vote up
public ReferralServiceVo save(ReferralServiceVo value) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException
{
	if (value != null)
	{
		if (!value.isValidated())
		{
			throw new DomainRuntimeException("ReferralServiceVo not validated");
		}

		DomainFactory factory = getDomainFactory();
		ReferralService doReferralService = ReferralServiceVoAssembler.extractReferralService(factory, value);
		factory.save(doReferralService);
		ReferralServiceVo savedValue = ReferralServiceVoAssembler.create(doReferralService);
	return savedValue ;
		
	}
	return null;
}
 
Example 36
Project: AvoinApotti   File: GPPracticeAdminImpl.java   View source code 6 votes vote down vote up
public void deletePractice(OrganisationVo orgToDelete) throws ForeignKeyViolationException
{
	if(orgToDelete == null)
		throw new RuntimeException("Cannot delete null OrganisationVo");
		
	DomainFactory factory = getDomainFactory();

	Organisation doOrganisation = OrganisationVoAssembler.extractOrganisation(factory, orgToDelete);
	
	if (doOrganisation.getLocationSites().size() > 0)
	{
		throw new ForeignKeyViolationException("There are Surgeries associated with this Practice. Cannot delete.");
	}
	
	factory.delete(doOrganisation);
}
 
Example 37
Project: AvoinApotti   File: GPPracticeAdminImpl.java   View source code 6 votes vote down vote up
public OrganisationVo deleteLocSite(LocSiteVo locSiteToDelete) throws ForeignKeyViolationException
{
	if(locSiteToDelete == null)
		throw new RuntimeException("Cannot delete null LocSiteVo");
	
	DomainFactory factory = getDomainFactory();

	LocSite doLocSite = LocSiteVoAssembler.extractLocSite(factory, locSiteToDelete);

	if(doLocSite==null)
		return null;
	
	Organisation doParentOrganisation = doLocSite.getParentOrganisation();

	if (doParentOrganisation != null)
		doParentOrganisation.getLocationSites().remove(doLocSite);
	//WDEV-12000 
	else
		return null;

	factory.delete(doLocSite);
	return OrganisationVoAssembler.create(doParentOrganisation); 
}
 
Example 38
Project: AvoinApotti   File: OrganisationAndLocationImpl.java   View source code 6 votes vote down vote up
public void deleteOrganisation(OrganisationVo orgToDelete) throws ForeignKeyViolationException
{
	DomainFactory factory = getDomainFactory();

	Organisation doOrganisation = OrganisationVoAssembler.extractOrganisation(factory, orgToDelete);
	Organisation doParentOrg = doOrganisation.getParentOrganisation();
	if (doParentOrg != null)
	{
		doParentOrg.getRelatedOrganisations().remove(doOrganisation);
	}
	
	// WDEV - 12551 - Display an appropriate message
	// when deleting fails
	try
	{
		factory.delete(doOrganisation);
	}
	catch (Exception ex)
	{
		throw new ForeignKeyViolationException("Organization is in use and can not be deleted.");
	}
}
 
Example 39
Project: AvoinApotti   File: LocationServiceImpl.java   View source code 6 votes vote down vote up
public ims.core.vo.LocationServiceVo saveLocationService(ims.core.vo.LocationServiceVo locationService) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException, ims.domain.exceptions.UniqueKeyViolationException
{
	DomainFactory factory = getDomainFactory();
	LocationService doLocService = LocationServiceVoAssembler.extractLocationService(factory, locationService);

	try
	{
		factory.save(doLocService);
		locationService = LocationServiceVoAssembler.create(doLocService);
	}
	catch (UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException(locationService.getService().getServiceName().toString() + " already exists. Duplicates not allowed.", e);
	}

	return locationService;
}
 
Example 40
Project: AvoinApotti   File: LocationServiceImpl.java   View source code 6 votes vote down vote up
public void removeLocationService(ims.core.vo.LocationServiceVo voLocationService) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException
{
	DomainFactory factory = getDomainFactory();
	LocationService doLocService = LocationServiceVoAssembler.extractLocationService(factory, voLocationService);
	try
	{
		try
		{
			factory.delete(doLocService);
		}
		catch (ForeignKeyViolationException e)
		{
			throw new ForeignKeyViolationException(e.getMessage());
		}
	}
	catch (DomainRuntimeException re) // SN: catching
										// DomainRuntimeException here as
										// this is what Hib is returning
										// with e.getCause() =
										// ConstrainViolationException
	{
		throw new ForeignKeyViolationException(re.getMessage());
	}
	return;
}