src/main/java/gov/usgs/cida/pubs/busservice/mp/MpPublicationCostCenterBusService.java
@Override
	public ValidationResults deleteObject(PublicationCostCenter<MpPublicationCostCenter> object) {
		MpPublicationCostCenter pubCostCenter = null;
		if (null != object && null != object.getId()) {
			pubCostCenter = MpPublicationCostCenter.getDao().getById(object.getId());
		} else if (null != object && null != object.getPublicationId() && null != object.getCostCenter().getId()) {
			Map<String, Object> filters = new HashMap<>();
			filters.put("publicationId", object.getPublicationId());
			filters.put("costCenterId", object.getCostCenter().getId());
			List<MpPublicationCostCenter> pubCostCenters = MpPublicationCostCenter.getDao().getByMap(filters);
			if (null != pubCostCenters && !pubCostCenters.isEmpty()) {
				//we should really only have one.
				pubCostCenter = pubCostCenters.get(0);
			}
		}
		if (null == pubCostCenter) {
			pubCostCenter = new MpPublicationCostCenter();
		} else {
			//only delete if we found it...
			Set<ConstraintViolation<MpPublicationCostCenter>> validations = validator.validate(pubCostCenter, DeleteChecks.class);
			if (!validations.isEmpty()) {
				pubCostCenter.setValidationErrors(validations);
			} else {
				MpPublicationCostCenter.getDao().delete(pubCostCenter);
			}
		}
		return pubCostCenter.getValidationErrors();
	}
/** 
	 * Cost center delete needs to deal with the association id possibly not being preserved.
	 */
Cost center delete needs to deal with the association id possibly not being preserved.
Cost center delete needs to deal with the association id possibly not being preserved .
@Override
	public ValidationResults deleteObject(PublicationCostCenter<MpPublicationCostCenter> object) {
		MpPublicationCostCenter pubCostCenter = null;
		if (null != object && null != object.getId()) {
			pubCostCenter = MpPublicationCostCenter.getDao().getById(object.getId());
		} else if (null != object && null != object.getPublicationId() && null != object.getCostCenter().getId()) {
			Map<String, Object> filters = new HashMap<>();
			filters.put("publicationId", object.getPublicationId());
			filters.put("costCenterId", object.getCostCenter().getId());
			List<MpPublicationCostCenter> pubCostCenters = MpPublicationCostCenter.getDao().getByMap(filters);
			if (null != pubCostCenters && !pubCostCenters.isEmpty()) {
				pubCostCenter = pubCostCenters.get(0);
			}
		}
		if (null == pubCostCenter) {
			pubCostCenter = new MpPublicationCostCenter();
		} else {
			Set<ConstraintViolation<MpPublicationCostCenter>> validations = validator.validate(pubCostCenter, DeleteChecks.class);
			if (!validations.isEmpty()) {
				pubCostCenter.setValidationErrors(validations);
			} else {
				MpPublicationCostCenter.getDao().delete(pubCostCenter);
			}
		}
		return pubCostCenter.getValidationErrors();
	}
@ Override public ValidationResults deleteObject ( PublicationCostCenter < MpPublicationCostCenter > object ) { MpPublicationCostCenter pubCostCenter = null ; if ( null != object && null != object . getId ( ) ) { pubCostCenter = MpPublicationCostCenter . getDao ( ) . getById ( object . getId ( ) ) ; } else if ( null != object && null != object . getPublicationId ( ) && null != object . getCostCenter ( ) . getId ( ) ) { Map < String , Object > filters = new HashMap < > ( ) ; filters . put ( "publicationId" , object . getPublicationId ( ) ) ; filters . put ( "costCenterId" , object . getCostCenter ( ) . getId ( ) ) ; List < MpPublicationCostCenter > pubCostCenters = MpPublicationCostCenter . getDao ( ) . getByMap ( filters ) ; if ( null != pubCostCenters && ! pubCostCenters . isEmpty ( ) ) { pubCostCenter = pubCostCenters . get ( 0 ) ; } } if ( null == pubCostCenter ) { pubCostCenter = new MpPublicationCostCenter ( ) ; } else { Set < ConstraintViolation < MpPublicationCostCenter > > validations = validator . validate ( pubCostCenter , DeleteChecks . class ) ; if ( ! validations . isEmpty ( ) ) { pubCostCenter . setValidationErrors ( validations ) ; } else { MpPublicationCostCenter . getDao ( ) . delete ( pubCostCenter ) ; } } return pubCostCenter . getValidationErrors ( ) ; }
Cost center delete needs to deal with the association id possibly not being preserved.
Cost center delete needs to deal with the association id possibly not being preserved .
//we should really only have one. //only delete if we found it...