001: // license-header java merge-point
002: /**
003: * This is only generated once! It will never be overwritten.
004: * You can (and have to!) safely modify it by hand.
005: */package org.andromda.timetracker.domain;
006:
007: import org.hibernate.Criteria;
008: import org.hibernate.FetchMode;
009: import org.hibernate.criterion.Restrictions;
010:
011: /**
012: * @see org.andromda.timetracker.domain.Timecard
013: */
014: public class TimecardDaoImpl extends
015: org.andromda.timetracker.domain.TimecardDaoBase {
016: /**
017: * @see org.andromda.timetracker.domain.TimecardDao#findByCriteria(org.andromda.timetracker.vo.TimecardSearchCriteriaVO)
018: */
019: protected java.util.List handleFindByCriteria(
020: org.andromda.timetracker.vo.TimecardSearchCriteriaVO criteria) {
021: // Create the timecard criteria
022: Criteria timecardCriteria = this .getSession().createCriteria(
023: Timecard.class).setFetchMode("submitter",
024: FetchMode.JOIN)
025: .setFetchMode("approver", FetchMode.JOIN);
026:
027: // Add submitter criteria
028: if (criteria.getSubmitterId() != null) {
029: timecardCriteria.createCriteria("submitter").add(
030: Restrictions.idEq(criteria.getSubmitterId()));
031: }
032:
033: // Add approver criteria
034: if (criteria.getApproverId() != null) {
035: timecardCriteria.createCriteria("approver").add(
036: Restrictions.idEq(criteria.getApproverId()));
037: }
038:
039: // Add status criteria
040: if (criteria.getStatus() != null) {
041: timecardCriteria.add(Restrictions.eq("status", criteria
042: .getStatus()));
043: }
044:
045: // Add startDateMin criteria
046: if (criteria.getStartDateMin() != null) {
047: timecardCriteria.add(Restrictions.ge("startDate", criteria
048: .getStartDateMin()));
049: }
050:
051: // Add startDateMax criteria
052: if (criteria.getStartDateMax() != null) {
053: timecardCriteria.add(Restrictions.le("startDate", criteria
054: .getStartDateMax()));
055: }
056:
057: java.util.List timecards = timecardCriteria.list();
058: if (logger.isDebugEnabled()) {
059: logger.debug(timecards.size() + " timecards found");
060: }
061: return timecards;
062: }
063:
064: /**
065: * @see org.andromda.timetracker.domain.TimecardDao#toTimecardSummaryVO(org.andromda.timetracker.domain.Timecard, org.andromda.timetracker.vo.TimecardSummaryVO)
066: */
067: public void toTimecardSummaryVO(
068: org.andromda.timetracker.domain.Timecard sourceEntity,
069: org.andromda.timetracker.vo.TimecardSummaryVO targetVO) {
070: super .toTimecardSummaryVO(sourceEntity, targetVO);
071: targetVO.setSubmitterName(sourceEntity.getSubmitter()
072: .getUsername());
073: if (sourceEntity.getApprover() != null) {
074: targetVO.setApproverName(sourceEntity.getApprover()
075: .getUsername());
076: }
077: }
078:
079: /**
080: * @see org.andromda.timetracker.domain.TimecardDao#toTimecardSummaryVO(org.andromda.timetracker.domain.Timecard)
081: */
082: public org.andromda.timetracker.vo.TimecardSummaryVO toTimecardSummaryVO(
083: final org.andromda.timetracker.domain.Timecard entity) {
084: // @todo verify behavior of toTimecardSummaryVO
085: return super .toTimecardSummaryVO(entity);
086: }
087:
088: /**
089: * Retrieves the entity object that is associated with the specified value object
090: * from the object store. If no such entity object exists in the object store,
091: * a new, blank entity is created
092: */
093: private org.andromda.timetracker.domain.Timecard loadTimecardFromTimecardSummaryVO(
094: org.andromda.timetracker.vo.TimecardSummaryVO timecardSummaryVO) {
095: // @todo implement loadTimecardFromTimecardSummaryVO
096: throw new java.lang.UnsupportedOperationException(
097: "org.andromda.timetracker.domain.loadTimecardFromTimecardSummaryVO(org.andromda.timetracker.vo.TimecardSummaryVO) not yet implemented.");
098:
099: /* A typical implementation looks like this:
100: org.andromda.timetracker.domain.Timecard timecard = this.load(timecardSummaryVO.getId());
101: if (timecard == null)
102: {
103: timecard = org.andromda.timetracker.domain.Timecard.Factory.newInstance();
104: }
105: return timecard;
106: */
107: }
108:
109: /**
110: * @see org.andromda.timetracker.domain.TimecardDao#timecardSummaryVOToEntity(org.andromda.timetracker.vo.TimecardSummaryVO)
111: */
112: public org.andromda.timetracker.domain.Timecard timecardSummaryVOToEntity(
113: org.andromda.timetracker.vo.TimecardSummaryVO timecardSummaryVO) {
114: // @todo verify behavior of timecardSummaryVOToEntity
115: org.andromda.timetracker.domain.Timecard entity = this
116: .loadTimecardFromTimecardSummaryVO(timecardSummaryVO);
117: this .timecardSummaryVOToEntity(timecardSummaryVO, entity, true);
118: return entity;
119: }
120:
121: /**
122: * @see org.andromda.timetracker.domain.TimecardDao#timecardSummaryVOToEntity(org.andromda.timetracker.vo.TimecardSummaryVO, org.andromda.timetracker.domain.Timecard)
123: */
124: public void timecardSummaryVOToEntity(
125: org.andromda.timetracker.vo.TimecardSummaryVO sourceVO,
126: org.andromda.timetracker.domain.Timecard targetEntity,
127: boolean copyIfNull) {
128: // @todo verify behavior of timecardSummaryVOToEntity
129: super .timecardSummaryVOToEntity(sourceVO, targetEntity,
130: copyIfNull);
131: }
132:
133: /**
134: * @see org.andromda.timetracker.domain.TimecardDao#toTimecardVO(org.andromda.timetracker.domain.Timecard, org.andromda.timetracker.vo.TimecardVO)
135: */
136: public void toTimecardVO(
137: org.andromda.timetracker.domain.Timecard sourceEntity,
138: org.andromda.timetracker.vo.TimecardVO targetVO) {
139: // @todo verify behavior of toTimecardVO
140: super .toTimecardVO(sourceEntity, targetVO);
141: // WARNING! No conversion for targetVO.allocations (can't convert sourceEntity.getAllocations():org.andromda.timetracker.domain.TimeAllocation to org.andromda.timetracker.vo.TimeAllocationVO[]
142: }
143:
144: /**
145: * @see org.andromda.timetracker.domain.TimecardDao#toTimecardVO(org.andromda.timetracker.domain.Timecard)
146: */
147: public org.andromda.timetracker.vo.TimecardVO toTimecardVO(
148: final org.andromda.timetracker.domain.Timecard entity) {
149: // @todo verify behavior of toTimecardVO
150: return super .toTimecardVO(entity);
151: }
152:
153: /**
154: * Retrieves the entity object that is associated with the specified value object
155: * from the object store. If no such entity object exists in the object store,
156: * a new, blank entity is created
157: */
158: private org.andromda.timetracker.domain.Timecard loadTimecardFromTimecardVO(
159: org.andromda.timetracker.vo.TimecardVO timecardVO) {
160: // @todo implement loadTimecardFromTimecardVO
161: throw new java.lang.UnsupportedOperationException(
162: "org.andromda.timetracker.domain.loadTimecardFromTimecardVO(org.andromda.timetracker.vo.TimecardVO) not yet implemented.");
163:
164: /* A typical implementation looks like this:
165: org.andromda.timetracker.domain.Timecard timecard = this.load(timecardVO.getId());
166: if (timecard == null)
167: {
168: timecard = org.andromda.timetracker.domain.Timecard.Factory.newInstance();
169: }
170: return timecard;
171: */
172: }
173:
174: /**
175: * @see org.andromda.timetracker.domain.TimecardDao#timecardVOToEntity(org.andromda.timetracker.vo.TimecardVO)
176: */
177: public org.andromda.timetracker.domain.Timecard timecardVOToEntity(
178: org.andromda.timetracker.vo.TimecardVO timecardVO) {
179: // @todo verify behavior of timecardVOToEntity
180: org.andromda.timetracker.domain.Timecard entity = this
181: .loadTimecardFromTimecardVO(timecardVO);
182: this .timecardVOToEntity(timecardVO, entity, true);
183: return entity;
184: }
185:
186: /**
187: * @see org.andromda.timetracker.domain.TimecardDao#timecardVOToEntity(org.andromda.timetracker.vo.TimecardVO, org.andromda.timetracker.domain.Timecard)
188: */
189: public void timecardVOToEntity(
190: org.andromda.timetracker.vo.TimecardVO sourceVO,
191: org.andromda.timetracker.domain.Timecard targetEntity,
192: boolean copyIfNull) {
193: // @todo verify behavior of timecardVOToEntity
194: super.timecardVOToEntity(sourceVO, targetEntity, copyIfNull);
195: }
196: }
|