| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.lum.lu.service.impl; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.HashMap; |
| 20 | |
import java.util.List; |
| 21 | |
import java.util.Map; |
| 22 | |
import java.util.Map.Entry; |
| 23 | |
|
| 24 | |
import org.kuali.student.core.dto.AmountInfo; |
| 25 | |
import org.kuali.student.core.dto.CurrencyAmountInfo; |
| 26 | |
import org.kuali.student.core.dto.TimeAmountInfo; |
| 27 | |
import org.kuali.student.core.entity.Amount; |
| 28 | |
import org.kuali.student.core.entity.CurrencyAmount; |
| 29 | |
import org.kuali.student.core.entity.TimeAmount; |
| 30 | |
import org.kuali.student.core.exceptions.DoesNotExistException; |
| 31 | |
import org.kuali.student.core.exceptions.InvalidParameterException; |
| 32 | |
import org.kuali.student.core.exceptions.VersionMismatchException; |
| 33 | |
import org.kuali.student.core.search.dto.SearchParam; |
| 34 | |
import org.kuali.student.core.service.impl.BaseAssembler; |
| 35 | |
import org.kuali.student.lum.lrc.dto.ResultComponentTypeInfo; |
| 36 | |
import org.kuali.student.lum.lu.dao.LuDao; |
| 37 | |
import org.kuali.student.lum.lu.dto.AccreditationInfo; |
| 38 | |
import org.kuali.student.lum.lu.dto.AdminOrgInfo; |
| 39 | |
import org.kuali.student.lum.lu.dto.AffiliatedOrgInfo; |
| 40 | |
import org.kuali.student.lum.lu.dto.CluAccountingInfo; |
| 41 | |
import org.kuali.student.lum.lu.dto.CluCluRelationInfo; |
| 42 | |
import org.kuali.student.lum.lu.dto.CluCreditInfo; |
| 43 | |
import org.kuali.student.lum.lu.dto.CluFeeInfo; |
| 44 | |
import org.kuali.student.lum.lu.dto.CluFeeRecordInfo; |
| 45 | |
import org.kuali.student.lum.lu.dto.CluIdentifierInfo; |
| 46 | |
import org.kuali.student.lum.lu.dto.CluInfo; |
| 47 | |
import org.kuali.student.lum.lu.dto.CluInstructorInfo; |
| 48 | |
import org.kuali.student.lum.lu.dto.CluLoRelationInfo; |
| 49 | |
import org.kuali.student.lum.lu.dto.CluLoRelationTypeInfo; |
| 50 | |
import org.kuali.student.lum.lu.dto.CluPublicationInfo; |
| 51 | |
import org.kuali.student.lum.lu.dto.CluResultInfo; |
| 52 | |
import org.kuali.student.lum.lu.dto.CluResultTypeInfo; |
| 53 | |
import org.kuali.student.lum.lu.dto.CluSetInfo; |
| 54 | |
import org.kuali.student.lum.lu.dto.CluSetTypeInfo; |
| 55 | |
import org.kuali.student.lum.lu.dto.DeliveryMethodTypeInfo; |
| 56 | |
import org.kuali.student.lum.lu.dto.FieldInfo; |
| 57 | |
import org.kuali.student.lum.lu.dto.InstructionalFormatTypeInfo; |
| 58 | |
import org.kuali.student.lum.lu.dto.LuCodeInfo; |
| 59 | |
import org.kuali.student.lum.lu.dto.LuCodeTypeInfo; |
| 60 | |
import org.kuali.student.lum.lu.dto.LuLuRelationTypeInfo; |
| 61 | |
import org.kuali.student.lum.lu.dto.LuPublicationTypeInfo; |
| 62 | |
import org.kuali.student.lum.lu.dto.LuTypeInfo; |
| 63 | |
import org.kuali.student.lum.lu.dto.LuiInfo; |
| 64 | |
import org.kuali.student.lum.lu.dto.LuiLuiRelationInfo; |
| 65 | |
import org.kuali.student.lum.lu.dto.MembershipQueryInfo; |
| 66 | |
import org.kuali.student.lum.lu.dto.ResultOptionInfo; |
| 67 | |
import org.kuali.student.lum.lu.dto.ResultUsageTypeInfo; |
| 68 | |
import org.kuali.student.lum.lu.entity.AffiliatedOrg; |
| 69 | |
import org.kuali.student.lum.lu.entity.Clu; |
| 70 | |
import org.kuali.student.lum.lu.entity.CluAccounting; |
| 71 | |
import org.kuali.student.lum.lu.entity.CluAccreditation; |
| 72 | |
import org.kuali.student.lum.lu.entity.CluAdminOrg; |
| 73 | |
import org.kuali.student.lum.lu.entity.CluAtpTypeKey; |
| 74 | |
import org.kuali.student.lum.lu.entity.CluCampusLocation; |
| 75 | |
import org.kuali.student.lum.lu.entity.CluCluRelation; |
| 76 | |
import org.kuali.student.lum.lu.entity.CluCredit; |
| 77 | |
import org.kuali.student.lum.lu.entity.CluFee; |
| 78 | |
import org.kuali.student.lum.lu.entity.CluFeeAmount; |
| 79 | |
import org.kuali.student.lum.lu.entity.CluFeeAttribute; |
| 80 | |
import org.kuali.student.lum.lu.entity.CluFeeRecord; |
| 81 | |
import org.kuali.student.lum.lu.entity.CluFeeRecordAttribute; |
| 82 | |
import org.kuali.student.lum.lu.entity.CluIdentifier; |
| 83 | |
import org.kuali.student.lum.lu.entity.CluInstructor; |
| 84 | |
import org.kuali.student.lum.lu.entity.CluLoRelation; |
| 85 | |
import org.kuali.student.lum.lu.entity.CluLoRelationType; |
| 86 | |
import org.kuali.student.lum.lu.entity.CluPublication; |
| 87 | |
import org.kuali.student.lum.lu.entity.CluPublicationVariant; |
| 88 | |
import org.kuali.student.lum.lu.entity.CluResult; |
| 89 | |
import org.kuali.student.lum.lu.entity.CluResultType; |
| 90 | |
import org.kuali.student.lum.lu.entity.CluSet; |
| 91 | |
import org.kuali.student.lum.lu.entity.CluSetAttribute; |
| 92 | |
import org.kuali.student.lum.lu.entity.CluSetJoinVersionIndClu; |
| 93 | |
import org.kuali.student.lum.lu.entity.CluSetType; |
| 94 | |
import org.kuali.student.lum.lu.entity.DeliveryMethodType; |
| 95 | |
import org.kuali.student.lum.lu.entity.InstructionalFormatType; |
| 96 | |
import org.kuali.student.lum.lu.entity.LuCode; |
| 97 | |
import org.kuali.student.lum.lu.entity.LuCodeType; |
| 98 | |
import org.kuali.student.lum.lu.entity.LuLuRelationType; |
| 99 | |
import org.kuali.student.lum.lu.entity.LuPublicationType; |
| 100 | |
import org.kuali.student.lum.lu.entity.LuRichText; |
| 101 | |
import org.kuali.student.lum.lu.entity.LuType; |
| 102 | |
import org.kuali.student.lum.lu.entity.Lui; |
| 103 | |
import org.kuali.student.lum.lu.entity.LuiAttribute; |
| 104 | |
import org.kuali.student.lum.lu.entity.LuiLuiRelation; |
| 105 | |
import org.kuali.student.lum.lu.entity.MembershipQuery; |
| 106 | |
import org.kuali.student.lum.lu.entity.ResultOption; |
| 107 | |
import org.kuali.student.lum.lu.entity.ResultUsageType; |
| 108 | |
import org.kuali.student.lum.lu.entity.SearchParameter; |
| 109 | |
import org.kuali.student.lum.lu.entity.SearchParameterValue; |
| 110 | |
import org.springframework.beans.BeanUtils; |
| 111 | |
|
| 112 | 0 | public class LuServiceAssembler extends BaseAssembler { |
| 113 | |
|
| 114 | |
public static List<CluLoRelationTypeInfo> toCluLoRelationTypeInfos( |
| 115 | |
List<CluLoRelationType> entities) { |
| 116 | 0 | return toGenericTypeInfoList(CluLoRelationTypeInfo.class, entities); |
| 117 | |
} |
| 118 | |
|
| 119 | |
public static CluLoRelationTypeInfo toCluLoRelationTypeInfo( |
| 120 | |
CluLoRelationType entity) { |
| 121 | 0 | return toGenericTypeInfo(CluLoRelationTypeInfo.class, entity); |
| 122 | |
} |
| 123 | |
|
| 124 | |
public static List<CluCluRelationInfo> toCluCluRelationInfos( |
| 125 | |
List<CluCluRelation> entities) { |
| 126 | 79 | List<CluCluRelationInfo> dtos = new ArrayList<CluCluRelationInfo>( |
| 127 | |
entities.size()); |
| 128 | 79 | if (entities != null) { |
| 129 | 79 | for (CluCluRelation entity : entities) { |
| 130 | 204 | dtos.add(toCluCluRelationInfo(entity)); |
| 131 | |
} |
| 132 | |
} |
| 133 | 79 | return dtos; |
| 134 | |
|
| 135 | |
} |
| 136 | |
|
| 137 | |
public static CluCluRelationInfo toCluCluRelationInfo(CluCluRelation entity) { |
| 138 | 383 | if (entity == null) { |
| 139 | 0 | return null; |
| 140 | |
} |
| 141 | 383 | CluCluRelationInfo dto = new CluCluRelationInfo(); |
| 142 | 383 | BeanUtils.copyProperties(entity, dto, |
| 143 | |
new String[] { "cluId", "relatedCluId", "cluRelationRequired", |
| 144 | |
"attributes", "metaInfo" }); |
| 145 | |
|
| 146 | 383 | dto.setIsCluRelationRequired(entity.isCluRelationRequired()); |
| 147 | 383 | dto.setCluId(entity.getClu().getId()); |
| 148 | 383 | dto.setRelatedCluId(entity.getRelatedClu().getId()); |
| 149 | 383 | dto.setType(entity.getLuLuRelationType().getId()); |
| 150 | 383 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 151 | 383 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 152 | |
|
| 153 | 383 | return dto; |
| 154 | |
|
| 155 | |
} |
| 156 | |
|
| 157 | |
public static List<CluLoRelationInfo> toCluLoRelationInfos( |
| 158 | |
List<CluLoRelation> entities) { |
| 159 | |
|
| 160 | 183 | List<CluLoRelationInfo> dtos = new ArrayList<CluLoRelationInfo>( |
| 161 | |
entities.size()); |
| 162 | 183 | if (entities != null) { |
| 163 | 183 | for (CluLoRelation entity : entities) { |
| 164 | 105 | dtos.add(toCluLoRelationInfo(entity)); |
| 165 | |
} |
| 166 | |
} |
| 167 | 183 | return dtos; |
| 168 | |
} |
| 169 | |
|
| 170 | |
public static CluLoRelationInfo toCluLoRelationInfo(CluLoRelation entity) { |
| 171 | 206 | if (entity == null) { |
| 172 | 0 | return null; |
| 173 | |
} |
| 174 | 206 | CluLoRelationInfo dto = new CluLoRelationInfo(); |
| 175 | 206 | BeanUtils.copyProperties(entity, dto, new String[] { "cluId", |
| 176 | |
"attributes", "metaInfo", "type" }); |
| 177 | |
|
| 178 | 206 | dto.setCluId(entity.getClu().getId()); |
| 179 | 206 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 180 | 206 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 181 | 206 | dto.setType(entity.getType().getId()); |
| 182 | |
|
| 183 | 206 | return dto; |
| 184 | |
} |
| 185 | |
|
| 186 | |
public static List<CluInfo> toCluInfos(List<Clu> entities) { |
| 187 | |
|
| 188 | |
|
| 189 | 69 | if (entities == null) { |
| 190 | 0 | return new ArrayList<CluInfo>(0); |
| 191 | |
} |
| 192 | |
|
| 193 | 69 | List<CluInfo> dtos = new ArrayList<CluInfo>(entities.size()); |
| 194 | 69 | for (Clu entity : entities) { |
| 195 | 110 | dtos.add(toCluInfo(entity)); |
| 196 | |
} |
| 197 | 69 | return dtos; |
| 198 | |
|
| 199 | |
} |
| 200 | |
|
| 201 | |
public static CluInfo toCluInfo(Clu entity) { |
| 202 | 708 | if (entity == null) { |
| 203 | 0 | return null; |
| 204 | |
} |
| 205 | 708 | CluInfo dto = new CluInfo(); |
| 206 | |
|
| 207 | |
|
| 208 | 708 | BeanUtils.copyProperties(entity, dto, new String[] { |
| 209 | |
"officialIdentifier", "alternateIdentifiers", "descr", |
| 210 | |
"participatingOrgs", "primaryInstructor", "instructors", |
| 211 | |
"stdDuration", "luCodes", "credit", "offeredAtpTypes", "fee", |
| 212 | |
"accounting", "intensity", |
| 213 | |
"campusLocationList", "accreditationList", |
| 214 | |
"adminOrgs", "attributes", "metaInfo", "versionInfo" }); |
| 215 | 708 | dto.setOfficialIdentifier(toCluIdentifierInfo(entity |
| 216 | |
.getOfficialIdentifier())); |
| 217 | 708 | dto.setAlternateIdentifiers(toCluIdentifierInfos(entity |
| 218 | |
.getAlternateIdentifiers())); |
| 219 | 708 | dto.setDescr(toRichTextInfo(entity.getDescr())); |
| 220 | |
|
| 221 | |
|
| 222 | |
|
| 223 | 708 | dto.setAccreditations(toAccreditationInfos(entity.getAccreditations())); |
| 224 | |
|
| 225 | 708 | dto.setAdminOrgs(toCluAdminOrgInfos(entity |
| 226 | |
.getAdminOrgs())); |
| 227 | |
|
| 228 | 708 | dto.setPrimaryInstructor(toCluInstructorInfo(entity |
| 229 | |
.getPrimaryInstructor())); |
| 230 | 708 | dto.setInstructors(toCluInstructorInfos(entity.getInstructors())); |
| 231 | 708 | dto.setStdDuration(toTimeAmountInfo(entity.getStdDuration())); |
| 232 | 708 | dto.setLuCodes(toLuCodeInfos(entity.getLuCodes())); |
| 233 | |
|
| 234 | 708 | if (entity.getOfferedAtpTypes() != null) { |
| 235 | 708 | List<String> offeredAtpTypes = new ArrayList<String>(entity |
| 236 | |
.getOfferedAtpTypes().size()); |
| 237 | 708 | for (CluAtpTypeKey key : entity.getOfferedAtpTypes()) { |
| 238 | 171 | offeredAtpTypes.add(key.getAtpTypeKey()); |
| 239 | |
} |
| 240 | 708 | dto.setOfferedAtpTypes(offeredAtpTypes); |
| 241 | |
} |
| 242 | |
|
| 243 | 708 | dto.setFeeInfo(toCluFeeInfo(entity.getFee())); |
| 244 | 708 | dto.setAccountingInfo(toCluAccountingInfo(entity.getAccounting())); |
| 245 | |
|
| 246 | 708 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 247 | 708 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 248 | |
|
| 249 | 708 | dto.setType(entity.getLuType().getId()); |
| 250 | |
|
| 251 | 708 | if (entity.getCampusLocations() != null) { |
| 252 | 708 | List<String> campusLocations = new ArrayList<String>(entity |
| 253 | |
.getCampusLocations().size()); |
| 254 | 708 | for (CluCampusLocation cluCamp : entity.getCampusLocations()) { |
| 255 | 448 | campusLocations.add(cluCamp.getCampusLocation()); |
| 256 | |
} |
| 257 | 708 | dto.setCampusLocations(campusLocations); |
| 258 | |
} |
| 259 | |
|
| 260 | 708 | dto.setIntensity(toAmountInfo(entity.getIntensity())); |
| 261 | |
|
| 262 | 708 | dto.setVersionInfo(toVersionInfo(entity.getVersion())); |
| 263 | |
|
| 264 | 708 | return dto; |
| 265 | |
|
| 266 | |
} |
| 267 | |
|
| 268 | |
public static List<CluSetInfo> toCluSetInfos(List<CluSet> entities) { |
| 269 | 4 | List<CluSetInfo> dtos = new ArrayList<CluSetInfo>(entities.size()); |
| 270 | 4 | if (entities != null) { |
| 271 | 4 | for (CluSet entity : entities) { |
| 272 | 7 | dtos.add(toCluSetInfo(entity)); |
| 273 | |
} |
| 274 | |
} |
| 275 | 4 | return dtos; |
| 276 | |
} |
| 277 | |
|
| 278 | |
public static CluSet toCluSetEntity(CluSetInfo cluSetInfo, LuDao luDao) throws InvalidParameterException, DoesNotExistException { |
| 279 | 36 | CluSet cluSet = new CluSet(); |
| 280 | |
|
| 281 | 36 | BeanUtils.copyProperties(cluSetInfo, cluSet, new String[] { "id", |
| 282 | |
"descr", "attributes", "metaInfo", "membershipQuery" }); |
| 283 | 36 | cluSet.setAttributes(toGenericAttributes( |
| 284 | |
CluSetAttribute.class, cluSetInfo.getAttributes(), cluSet, luDao)); |
| 285 | 36 | cluSet.setType(cluSetInfo.getType()); |
| 286 | 36 | cluSet.setDescr(toRichText(LuRichText.class, cluSetInfo.getDescr())); |
| 287 | |
|
| 288 | 36 | for (String cluId : cluSetInfo.getCluIds()) { |
| 289 | 11 | CluSetJoinVersionIndClu join = new CluSetJoinVersionIndClu(); |
| 290 | 11 | join.setCluSet(cluSet); |
| 291 | 11 | join.setCluVersionIndId(cluId); |
| 292 | 11 | cluSet.getCluVerIndIds().add(join); |
| 293 | 11 | } |
| 294 | 36 | for (String cluSetId : cluSetInfo.getCluSetIds()) { |
| 295 | 9 | CluSet c = luDao.fetch(CluSet.class, cluSetId); |
| 296 | 9 | if(cluSet.getCluSets()==null){ |
| 297 | 0 | cluSet.setCluSets(new ArrayList<CluSet>()); |
| 298 | |
} |
| 299 | 9 | cluSet.getCluSets().add(c); |
| 300 | 9 | } |
| 301 | 36 | cluSet.setMembershipQuery(toMembershipQueryEntity(cluSetInfo.getMembershipQuery())); |
| 302 | |
|
| 303 | 36 | return cluSet; |
| 304 | |
} |
| 305 | |
|
| 306 | |
public static CluSetInfo toCluSetInfo(CluSet entity) { |
| 307 | 148 | if (entity == null) { |
| 308 | 0 | return null; |
| 309 | |
} |
| 310 | 148 | CluSetInfo dto = new CluSetInfo(); |
| 311 | |
|
| 312 | 148 | BeanUtils.copyProperties(entity, dto, new String[] { "descr", |
| 313 | |
"cluCriteria", "cluSets", "clus", "attributes", "metaInfo", "membershipQuery" }); |
| 314 | |
|
| 315 | 148 | dto.setDescr(toRichTextInfo(entity.getDescr())); |
| 316 | |
|
| 317 | 148 | if(entity.getCluSets()!=null){ |
| 318 | 142 | List<String> cluSetIds = new ArrayList<String>(entity.getCluSets() |
| 319 | |
.size()); |
| 320 | 142 | for (CluSet id : entity.getCluSets()) { |
| 321 | 49 | cluSetIds.add(id.getId()); |
| 322 | |
} |
| 323 | 142 | dto.setCluSetIds(cluSetIds); |
| 324 | |
} |
| 325 | |
|
| 326 | 148 | List<String> cluIds = new ArrayList<String>(entity.getCluVerIndIds().size()); |
| 327 | 148 | for (CluSetJoinVersionIndClu join : entity.getCluVerIndIds()) { |
| 328 | 160 | cluIds.add(join.getCluVersionIndId()); |
| 329 | |
} |
| 330 | 148 | dto.setCluIds(cluIds); |
| 331 | |
|
| 332 | 148 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 333 | 148 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 334 | |
|
| 335 | 148 | MembershipQueryInfo mqInfo = toMembershipQueryInfo(entity.getMembershipQuery()); |
| 336 | 148 | dto.setMembershipQuery(mqInfo); |
| 337 | 148 | dto.setIsReusable(entity.getIsReusable()); |
| 338 | 148 | dto.setIsReferenceable(entity.getIsReferenceable()); |
| 339 | |
|
| 340 | 148 | return dto; |
| 341 | |
} |
| 342 | |
|
| 343 | |
public static MembershipQueryInfo toMembershipQueryInfo(MembershipQuery entity) { |
| 344 | 148 | if(entity == null) { |
| 345 | 136 | return null; |
| 346 | |
} |
| 347 | 12 | MembershipQueryInfo dto = new MembershipQueryInfo(); |
| 348 | 12 | dto.setId(entity.getId()); |
| 349 | 12 | dto.setSearchTypeKey(entity.getSearchTypeKey()); |
| 350 | 12 | List<SearchParam> list = new ArrayList<SearchParam>(); |
| 351 | 12 | for(SearchParameter param : entity.getSearchParameters()) { |
| 352 | 10 | SearchParam sp = toSearchParam(param); |
| 353 | 10 | list.add(sp); |
| 354 | 10 | } |
| 355 | 12 | dto.setQueryParamValueList(list); |
| 356 | |
|
| 357 | 12 | return dto; |
| 358 | |
} |
| 359 | |
|
| 360 | |
public static SearchParam toSearchParam(SearchParameter entity) { |
| 361 | 10 | SearchParam dto = new SearchParam(); |
| 362 | 10 | dto.setKey(entity.getKey()); |
| 363 | 10 | List<String> values = new ArrayList<String>(); |
| 364 | 10 | for(SearchParameterValue value : entity.getValues()) { |
| 365 | 10 | values.add(value.getValue()); |
| 366 | |
} |
| 367 | 10 | dto.setValue(values); |
| 368 | 10 | if(entity.getValues().size() == 1) { |
| 369 | 10 | dto.setValue(entity.getValues().get(0).getValue()); |
| 370 | |
} |
| 371 | 10 | return dto; |
| 372 | |
} |
| 373 | |
|
| 374 | |
public static MembershipQuery toMembershipQueryEntity(MembershipQueryInfo dto) { |
| 375 | 45 | if(dto == null) { |
| 376 | 38 | return null; |
| 377 | |
} |
| 378 | 7 | MembershipQuery entity = new MembershipQuery(); |
| 379 | 7 | entity.setSearchTypeKey(dto.getSearchTypeKey()); |
| 380 | 7 | List<SearchParameter> list = new ArrayList<SearchParameter>(); |
| 381 | 7 | for(SearchParam param : dto.getQueryParamValueList()) { |
| 382 | 6 | SearchParameter sp = toSearchParameterEntity(param); |
| 383 | 6 | list.add(sp); |
| 384 | 6 | } |
| 385 | 7 | entity.setSearchParameters(list); |
| 386 | |
|
| 387 | 7 | return entity; |
| 388 | |
} |
| 389 | |
|
| 390 | |
public static SearchParameter toSearchParameterEntity(SearchParam dto) { |
| 391 | 6 | if(dto == null) { |
| 392 | 0 | return null; |
| 393 | |
} |
| 394 | 6 | SearchParameter entity = new SearchParameter(); |
| 395 | 6 | entity.setKey(dto.getKey()); |
| 396 | 6 | List<SearchParameterValue> values = new ArrayList<SearchParameterValue>(); |
| 397 | 6 | if(dto.getValue() instanceof String) { |
| 398 | 6 | SearchParameterValue value = new SearchParameterValue(); |
| 399 | 6 | value.setValue((String) dto.getValue()); |
| 400 | 6 | values.add(value); |
| 401 | 6 | } else if(dto.getValue() instanceof List<?>) { |
| 402 | 0 | List<String> stringList = (List<String>)dto.getValue(); |
| 403 | 0 | for(String s : stringList) { |
| 404 | 0 | SearchParameterValue value = new SearchParameterValue(); |
| 405 | 0 | value.setValue(s); |
| 406 | 0 | values.add(value); |
| 407 | 0 | } |
| 408 | |
} |
| 409 | 6 | entity.setValues(values); |
| 410 | 6 | return entity; |
| 411 | |
} |
| 412 | |
|
| 413 | |
public static List<ResultUsageTypeInfo> toResultUsageTypeInfos( |
| 414 | |
List<ResultUsageType> entities) { |
| 415 | 1 | return toGenericTypeInfoList(ResultUsageTypeInfo.class, entities); |
| 416 | |
} |
| 417 | |
|
| 418 | |
public static ResultUsageTypeInfo toResultUsageTypeInfo( |
| 419 | |
ResultUsageType entity) { |
| 420 | 1 | return toGenericTypeInfo(ResultUsageTypeInfo.class, entity); |
| 421 | |
} |
| 422 | |
|
| 423 | |
public static List<DeliveryMethodTypeInfo> toDeliveryMethodTypeInfos( |
| 424 | |
List<DeliveryMethodType> entities) { |
| 425 | 0 | return toGenericTypeInfoList(DeliveryMethodTypeInfo.class, entities); |
| 426 | |
} |
| 427 | |
|
| 428 | |
public static DeliveryMethodTypeInfo toDeliveryMethodTypeInfo( |
| 429 | |
DeliveryMethodType entity) { |
| 430 | 0 | return toGenericTypeInfo(DeliveryMethodTypeInfo.class, entity); |
| 431 | |
} |
| 432 | |
|
| 433 | |
public static List<InstructionalFormatTypeInfo> toInstructionalFormatTypeInfos( |
| 434 | |
List<InstructionalFormatType> entities) { |
| 435 | 0 | return toGenericTypeInfoList(InstructionalFormatTypeInfo.class, |
| 436 | |
entities); |
| 437 | |
} |
| 438 | |
|
| 439 | |
public static InstructionalFormatTypeInfo toInstructionalFormatTypeInfo( |
| 440 | |
InstructionalFormatType entity) { |
| 441 | 0 | return toGenericTypeInfo(InstructionalFormatTypeInfo.class, entity); |
| 442 | |
} |
| 443 | |
|
| 444 | |
public static List<LuCodeTypeInfo> toLuCodeTypeInfos( |
| 445 | |
List<LuCodeType> entities) { |
| 446 | 0 | return toGenericTypeInfoList(LuCodeTypeInfo.class, entities); |
| 447 | |
} |
| 448 | |
|
| 449 | |
public static LuCodeTypeInfo toLuCodeTypeInfo(LuCodeType entity) { |
| 450 | 0 | return toGenericTypeInfo(LuCodeTypeInfo.class, entity); |
| 451 | |
} |
| 452 | |
|
| 453 | |
public static List<CluResultTypeInfo> toCluResultTypeInfos( |
| 454 | |
List<CluResultType> entities) { |
| 455 | 0 | return toGenericTypeInfoList(CluResultTypeInfo.class, entities); |
| 456 | |
} |
| 457 | |
|
| 458 | |
public static CluResultTypeInfo toCluResultTypeInfo(CluResultType entity) { |
| 459 | 235 | return toGenericTypeInfo(CluResultTypeInfo.class, entity); |
| 460 | |
} |
| 461 | |
|
| 462 | |
public static CluSetTypeInfo toCluSetTypeInfo(CluSetType entity) { |
| 463 | 0 | return toGenericTypeInfo(CluSetTypeInfo.class, entity); |
| 464 | |
} |
| 465 | |
|
| 466 | |
public static List<CluSetTypeInfo> toCluSetTypeInfos( |
| 467 | |
List<CluSetType> entities) { |
| 468 | 0 | return toGenericTypeInfoList(CluSetTypeInfo.class, entities); |
| 469 | |
} |
| 470 | |
|
| 471 | |
public static CluResultInfo toCluResultInfo(CluResult entity) { |
| 472 | 235 | if (entity == null) { |
| 473 | 0 | return null; |
| 474 | |
} |
| 475 | |
|
| 476 | 235 | CluResultInfo dto = new CluResultInfo(); |
| 477 | |
|
| 478 | 235 | BeanUtils.copyProperties(entity, dto, new String[] { "resultOptions", "desc" }); |
| 479 | |
|
| 480 | 235 | List<ResultOptionInfo> resultOptions = toResultOptionInfos(entity.getResultOptions()); |
| 481 | 235 | dto.setResultOptions(resultOptions); |
| 482 | 235 | dto.setDesc(toRichTextInfo(entity.getDesc())); |
| 483 | 235 | dto.setCluId(entity.getClu().getId()); |
| 484 | 235 | CluResultTypeInfo type = toCluResultTypeInfo(entity.getCluResultType()); |
| 485 | 235 | if(type!=null){ |
| 486 | 235 | dto.setType(type.getId()); |
| 487 | |
} |
| 488 | 235 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 489 | |
|
| 490 | 235 | return dto; |
| 491 | |
} |
| 492 | |
|
| 493 | |
public static List<CluResultInfo> toCluResultInfos(List<CluResult> entities) { |
| 494 | 122 | List<CluResultInfo> dtos = new ArrayList<CluResultInfo>(); |
| 495 | 122 | if (entities != null) { |
| 496 | 122 | for (CluResult entity : entities) { |
| 497 | 124 | dtos.add(toCluResultInfo(entity)); |
| 498 | |
} |
| 499 | |
} |
| 500 | 122 | return dtos; |
| 501 | |
} |
| 502 | |
|
| 503 | |
public static List<ResultOptionInfo> toResultOptionInfos( |
| 504 | |
List<ResultOption> entities) { |
| 505 | 235 | List<ResultOptionInfo> dtos = new ArrayList<ResultOptionInfo>(); |
| 506 | 235 | if (entities != null) { |
| 507 | 235 | for (ResultOption entity : entities) { |
| 508 | 316 | dtos.add(toResultOptionInfo(entity)); |
| 509 | |
} |
| 510 | |
} |
| 511 | 235 | return dtos; |
| 512 | |
} |
| 513 | |
|
| 514 | |
public static ResultOptionInfo toResultOptionInfo(ResultOption entity) { |
| 515 | 316 | if (entity == null) { |
| 516 | 0 | return null; |
| 517 | |
} |
| 518 | |
|
| 519 | 316 | ResultOptionInfo dto = new ResultOptionInfo(); |
| 520 | |
|
| 521 | 316 | BeanUtils.copyProperties(entity, dto, new String[] { "resultUsageType", "desc" }); |
| 522 | 316 | if(entity.getResultUsageType() != null) { |
| 523 | 2 | dto.setResultUsageTypeKey(entity.getResultUsageType().getId()); |
| 524 | |
} |
| 525 | 316 | dto.setDesc(toRichTextInfo(entity.getDesc())); |
| 526 | 316 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 527 | |
|
| 528 | 316 | return dto; |
| 529 | |
} |
| 530 | |
|
| 531 | |
public static List<LuLuRelationTypeInfo> toLuLuRelationTypeInfos( |
| 532 | |
List<LuLuRelationType> entities) { |
| 533 | 1 | List<LuLuRelationTypeInfo> dtos = new ArrayList<LuLuRelationTypeInfo>( |
| 534 | |
entities.size()); |
| 535 | 1 | if(entities!=null){ |
| 536 | 1 | for (LuLuRelationType entity : entities) { |
| 537 | 13 | dtos.add(toLuLuRelationTypeInfo(entity)); |
| 538 | |
} |
| 539 | |
} |
| 540 | 1 | return dtos; |
| 541 | |
|
| 542 | |
} |
| 543 | |
|
| 544 | |
public static LuLuRelationTypeInfo toLuLuRelationTypeInfo( |
| 545 | |
LuLuRelationType entity) { |
| 546 | 15 | if (entity == null) { |
| 547 | 0 | return null; |
| 548 | |
} |
| 549 | 15 | LuLuRelationTypeInfo dto = new LuLuRelationTypeInfo(); |
| 550 | |
|
| 551 | 15 | BeanUtils.copyProperties(entity, dto, new String[] { "attributes" }); |
| 552 | 15 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 553 | |
|
| 554 | 15 | return dto; |
| 555 | |
} |
| 556 | |
|
| 557 | |
public static List<LuTypeInfo> toLuTypeInfos(List<LuType> entities) { |
| 558 | 0 | return toGenericTypeInfoList(LuTypeInfo.class, entities); |
| 559 | |
} |
| 560 | |
|
| 561 | |
public static LuTypeInfo toLuTypeInfo(LuType entity) { |
| 562 | 0 | LuTypeInfo typeInfo = toGenericTypeInfo(LuTypeInfo.class, entity); |
| 563 | 0 | typeInfo.setDeliveryMethod(entity.getDeliveryMethod()); |
| 564 | 0 | typeInfo.setInstructionalFormat(entity.getInstructionalFormat()); |
| 565 | |
|
| 566 | 0 | return typeInfo; |
| 567 | |
} |
| 568 | |
|
| 569 | |
public static List<LuiInfo> toLuiInfos(List<Lui> entities) { |
| 570 | 5 | List<LuiInfo> dtos = new ArrayList<LuiInfo>(entities.size()); |
| 571 | 5 | if (entities != null) { |
| 572 | 5 | for (Lui entity : entities) { |
| 573 | 5 | dtos.add(toLuiInfo(entity)); |
| 574 | |
} |
| 575 | |
} |
| 576 | 5 | return dtos; |
| 577 | |
|
| 578 | |
} |
| 579 | |
|
| 580 | |
public static LuiInfo toLuiInfo(Lui entity) { |
| 581 | 11 | if (entity == null) { |
| 582 | 0 | return null; |
| 583 | |
} |
| 584 | 11 | LuiInfo luiInfo = new LuiInfo(); |
| 585 | |
|
| 586 | 11 | BeanUtils.copyProperties(entity, luiInfo, new String[] { "clu", |
| 587 | |
"metaInfo", "attributes" }); |
| 588 | |
|
| 589 | 11 | luiInfo.setCluId(entity.getClu().getId()); |
| 590 | |
|
| 591 | 11 | luiInfo |
| 592 | |
.setMetaInfo(toMetaInfo(entity.getMeta(), entity |
| 593 | |
.getVersionNumber())); |
| 594 | |
|
| 595 | 11 | luiInfo.setAttributes(toAttributeMap(entity.getAttributes())); |
| 596 | |
|
| 597 | 11 | return luiInfo; |
| 598 | |
} |
| 599 | |
|
| 600 | |
public static Lui toLui(boolean isUpdate, LuiInfo luiInfo, LuDao dao) |
| 601 | |
throws DoesNotExistException, VersionMismatchException, |
| 602 | |
InvalidParameterException { |
| 603 | 2 | if (luiInfo == null) { |
| 604 | 0 | return null; |
| 605 | |
} |
| 606 | |
Lui lui; |
| 607 | |
|
| 608 | 2 | if (isUpdate) { |
| 609 | 0 | lui = dao.fetch(Lui.class, luiInfo.getId()); |
| 610 | 0 | if (null == lui) { |
| 611 | 0 | throw new DoesNotExistException((new StringBuilder()).append( |
| 612 | |
"Lui does not exist for id: ").append(luiInfo.getId()) |
| 613 | |
.toString()); |
| 614 | |
} |
| 615 | 0 | if (!String.valueOf(lui.getVersionNumber()).equals( |
| 616 | |
luiInfo.getMetaInfo().getVersionInd())) { |
| 617 | 0 | throw new VersionMismatchException( |
| 618 | |
"Lui to be updated is not the current version"); |
| 619 | |
} |
| 620 | |
} else { |
| 621 | 2 | lui = new Lui(); |
| 622 | |
} |
| 623 | |
|
| 624 | 2 | BeanUtils.copyProperties(luiInfo, lui, new String[] { "cluId", |
| 625 | |
"attributes", "metaInfo" }); |
| 626 | |
|
| 627 | 2 | lui.setAttributes(toGenericAttributes(LuiAttribute.class, luiInfo |
| 628 | |
.getAttributes(), lui, dao)); |
| 629 | |
|
| 630 | 2 | Clu clu = dao.fetch(Clu.class, luiInfo.getCluId()); |
| 631 | 2 | if (null == clu) { |
| 632 | 0 | throw new InvalidParameterException((new StringBuilder()).append( |
| 633 | |
"Clu does not exist for id: ").append(luiInfo.getCluId()) |
| 634 | |
.toString()); |
| 635 | |
} |
| 636 | 2 | lui.setClu(clu); |
| 637 | 2 | return lui; |
| 638 | |
} |
| 639 | |
|
| 640 | |
public static List<LuiLuiRelationInfo> toLuiLuiRelationInfos( |
| 641 | |
List<LuiLuiRelation> entities) { |
| 642 | 3 | List<LuiLuiRelationInfo> dtos = new ArrayList<LuiLuiRelationInfo>( |
| 643 | |
entities.size()); |
| 644 | 3 | if (entities != null) { |
| 645 | 3 | for (LuiLuiRelation entity : entities) { |
| 646 | 3 | dtos.add(toLuiLuiRelationInfo(entity)); |
| 647 | |
} |
| 648 | |
} |
| 649 | 3 | return dtos; |
| 650 | |
} |
| 651 | |
|
| 652 | |
public static LuiLuiRelationInfo toLuiLuiRelationInfo(LuiLuiRelation entity) { |
| 653 | 6 | if (entity == null) { |
| 654 | 0 | return null; |
| 655 | |
} |
| 656 | 6 | LuiLuiRelationInfo dto = new LuiLuiRelationInfo(); |
| 657 | |
|
| 658 | 6 | BeanUtils.copyProperties(entity, dto, new String[] { "lui", |
| 659 | |
"relatedLui", "attributes" }); |
| 660 | |
|
| 661 | 6 | dto.setLuiId(entity.getLui().getId()); |
| 662 | 6 | dto.setRelatedLuiId(entity.getRelatedLui().getId()); |
| 663 | 6 | dto.setType(entity.getLuLuRelationType().getId()); |
| 664 | 6 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 665 | 6 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 666 | 6 | return dto; |
| 667 | |
} |
| 668 | |
|
| 669 | |
public static List<CluIdentifierInfo> toCluIdentifierInfos( |
| 670 | |
List<CluIdentifier> entities) { |
| 671 | 708 | List<CluIdentifierInfo> dtos = new ArrayList<CluIdentifierInfo>( |
| 672 | |
entities.size()); |
| 673 | 708 | if(entities!=null){ |
| 674 | 708 | for (CluIdentifier entity : entities) { |
| 675 | 479 | dtos.add(toCluIdentifierInfo(entity)); |
| 676 | |
} |
| 677 | |
} |
| 678 | 708 | return dtos; |
| 679 | |
} |
| 680 | |
|
| 681 | |
public static CluIdentifierInfo toCluIdentifierInfo(CluIdentifier entity) { |
| 682 | 1187 | if (entity == null) { |
| 683 | 218 | return null; |
| 684 | |
} |
| 685 | |
|
| 686 | 969 | CluIdentifierInfo dto = new CluIdentifierInfo(); |
| 687 | |
|
| 688 | 969 | BeanUtils.copyProperties(entity, dto); |
| 689 | |
|
| 690 | 969 | return dto; |
| 691 | |
} |
| 692 | |
|
| 693 | |
public static List<CluInstructorInfo> toCluInstructorInfos( |
| 694 | |
List<CluInstructor> entities) { |
| 695 | 708 | List<CluInstructorInfo> dtos = new ArrayList<CluInstructorInfo>( |
| 696 | |
entities.size()); |
| 697 | 708 | if(entities!=null){ |
| 698 | 708 | for (CluInstructor entity : entities) { |
| 699 | 214 | dtos.add(toCluInstructorInfo(entity)); |
| 700 | |
} |
| 701 | |
} |
| 702 | 708 | return dtos; |
| 703 | |
} |
| 704 | |
|
| 705 | |
public static CluInstructorInfo toCluInstructorInfo(CluInstructor entity) { |
| 706 | 922 | if (entity == null) { |
| 707 | 297 | return null; |
| 708 | |
} |
| 709 | 625 | CluInstructorInfo dto = new CluInstructorInfo(); |
| 710 | |
|
| 711 | 625 | BeanUtils.copyProperties(entity, dto, |
| 712 | |
new String[] { "id", "attributes" }); |
| 713 | 625 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 714 | |
|
| 715 | 625 | return dto; |
| 716 | |
} |
| 717 | |
|
| 718 | |
public static AmountInfo toAmountInfo(Amount entity) { |
| 719 | 708 | if (entity == null) { |
| 720 | 360 | return null; |
| 721 | |
} |
| 722 | 348 | AmountInfo dto = new AmountInfo(); |
| 723 | |
|
| 724 | 348 | BeanUtils.copyProperties(entity, dto); |
| 725 | |
|
| 726 | 348 | return dto; |
| 727 | |
} |
| 728 | |
|
| 729 | |
public static TimeAmountInfo toTimeAmountInfo(TimeAmount entity) { |
| 730 | 708 | if (entity == null) { |
| 731 | 261 | return null; |
| 732 | |
} |
| 733 | 447 | TimeAmountInfo dto = new TimeAmountInfo(); |
| 734 | |
|
| 735 | 447 | BeanUtils.copyProperties(entity, dto); |
| 736 | |
|
| 737 | 447 | return dto; |
| 738 | |
} |
| 739 | |
|
| 740 | |
public static List<LuCodeInfo> toLuCodeInfos(List<LuCode> entities) { |
| 741 | 708 | List<LuCodeInfo> dtos = new ArrayList<LuCodeInfo>(entities.size()); |
| 742 | 708 | if(entities!=null){ |
| 743 | 708 | for (LuCode entity : entities) { |
| 744 | 736 | dtos.add(toLuCodeInfo(entity)); |
| 745 | |
} |
| 746 | |
} |
| 747 | 708 | return dtos; |
| 748 | |
} |
| 749 | |
|
| 750 | |
public static LuCodeInfo toLuCodeInfo(LuCode entity) { |
| 751 | 736 | if (entity == null) { |
| 752 | 0 | return null; |
| 753 | |
} |
| 754 | 736 | LuCodeInfo dto = new LuCodeInfo(); |
| 755 | |
|
| 756 | 736 | BeanUtils.copyProperties(entity, dto, new String[] { "attributes", |
| 757 | |
"metInfo" }); |
| 758 | |
|
| 759 | 736 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 760 | 736 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 761 | |
|
| 762 | 736 | return dto; |
| 763 | |
} |
| 764 | |
|
| 765 | |
public static CluCreditInfo toCluCreditInfos(CluCredit entity) { |
| 766 | 0 | if (entity == null) { |
| 767 | 0 | return null; |
| 768 | |
} |
| 769 | 0 | CluCreditInfo dto = new CluCreditInfo(); |
| 770 | |
|
| 771 | 0 | BeanUtils.copyProperties(entity, dto, new String[] { "id", |
| 772 | |
"repeatTime", "minTimeToComplete", "maxTimeToComplete", |
| 773 | |
"maxAllowableInactivity", "maxTimeResultsRecognized" }); |
| 774 | 0 | dto.setRepeatTime(toTimeAmountInfo(entity.getRepeatTime())); |
| 775 | 0 | dto |
| 776 | |
.setMinTimeToComplete(toTimeAmountInfo(entity |
| 777 | |
.getMinTimeToComplete())); |
| 778 | 0 | dto |
| 779 | |
.setMaxTimeToComplete(toTimeAmountInfo(entity |
| 780 | |
.getMaxTimeToComplete())); |
| 781 | 0 | dto.setMaxAllowableInactivity(toTimeAmountInfo(entity |
| 782 | |
.getMaxAllowableInactivity())); |
| 783 | 0 | dto.setMaxTimeResultsRecognized(toTimeAmountInfo(entity |
| 784 | |
.getMaxTimeResultsRecognized())); |
| 785 | |
|
| 786 | 0 | return dto; |
| 787 | |
} |
| 788 | |
|
| 789 | |
public static List<ResultComponentTypeInfo> toResultComponentTypeInfo( |
| 790 | |
List<String> componentIds) { |
| 791 | 0 | List<ResultComponentTypeInfo> dtos = new ArrayList<ResultComponentTypeInfo>(); |
| 792 | 0 | if(componentIds!=null){ |
| 793 | 0 | for (String id : componentIds) { |
| 794 | 0 | ResultComponentTypeInfo comp = new ResultComponentTypeInfo(); |
| 795 | 0 | comp.setId(id); |
| 796 | 0 | dtos.add(comp); |
| 797 | 0 | } |
| 798 | |
} |
| 799 | 0 | return dtos; |
| 800 | |
} |
| 801 | |
|
| 802 | |
public static CluFeeInfo toCluFeeInfo(CluFee entity) { |
| 803 | 708 | if (entity == null) { |
| 804 | 527 | return null; |
| 805 | |
} |
| 806 | 181 | CluFeeInfo dto = new CluFeeInfo(); |
| 807 | |
|
| 808 | 181 | dto.setCluFeeRecords(toCluFeeRecordInfos(entity.getCluFeeRecords())); |
| 809 | 181 | dto.setId(entity.getId()); |
| 810 | 181 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 811 | 181 | dto.setDescr(toRichTextInfo(entity.getDescr())); |
| 812 | 181 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 813 | |
|
| 814 | 181 | return dto; |
| 815 | |
} |
| 816 | |
|
| 817 | |
private static List<CluFeeRecordInfo> toCluFeeRecordInfos( |
| 818 | |
List<CluFeeRecord> entities) { |
| 819 | 181 | List<CluFeeRecordInfo> dtos = new ArrayList<CluFeeRecordInfo>(); |
| 820 | 181 | if (entities != null) { |
| 821 | 181 | for (CluFeeRecord record : entities) { |
| 822 | 353 | dtos.add(toCluFeeRecordInfo(record)); |
| 823 | |
} |
| 824 | |
} |
| 825 | 181 | return dtos; |
| 826 | |
} |
| 827 | |
|
| 828 | |
private static CluFeeRecordInfo toCluFeeRecordInfo(CluFeeRecord entity) { |
| 829 | 353 | if (entity == null) { |
| 830 | 0 | return null; |
| 831 | |
} |
| 832 | |
|
| 833 | 353 | CluFeeRecordInfo dto = new CluFeeRecordInfo(); |
| 834 | |
|
| 835 | 353 | BeanUtils.copyProperties(entity, dto, |
| 836 | |
new String[] { "affiliatedOrgs", "currencyAmount","attributes","descr" }); |
| 837 | |
|
| 838 | 353 | dto.setAffiliatedOrgs(toAffiliatedOrgInfos(entity.getAffiliatedOrgs())); |
| 839 | 353 | dto.setFeeAmounts(toFeeAmounts(entity.getFeeAmounts())); |
| 840 | 353 | dto.setDescr(toRichTextInfo(entity.getDescr())); |
| 841 | 353 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 842 | 353 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 843 | |
|
| 844 | 353 | return dto; |
| 845 | |
} |
| 846 | |
|
| 847 | |
private static List<CurrencyAmountInfo> toFeeAmounts(List<CluFeeAmount> cluFees) { |
| 848 | 353 | List<CurrencyAmountInfo> feeAmounts = new ArrayList<CurrencyAmountInfo>(); |
| 849 | |
|
| 850 | 353 | if (cluFees != null){ |
| 851 | 353 | for (CluFeeAmount cluFeeAmount:cluFees){ |
| 852 | 305 | CurrencyAmountInfo dto = new CurrencyAmountInfo(); |
| 853 | 305 | CurrencyAmount ca = cluFeeAmount.getCurrencyAmount(); |
| 854 | 305 | if(ca!=null){ |
| 855 | 300 | dto.setCurrencyQuantity(ca.getCurrencyQuantity()); |
| 856 | 300 | dto.setCurrencyTypeKey(ca.getCurrencyTypeKey()); |
| 857 | |
} |
| 858 | 305 | feeAmounts.add(dto); |
| 859 | 305 | } |
| 860 | |
} |
| 861 | |
|
| 862 | 353 | return feeAmounts; |
| 863 | |
} |
| 864 | |
|
| 865 | |
private static List<AffiliatedOrgInfo> toAffiliatedOrgInfos( |
| 866 | |
List<AffiliatedOrg> entities) { |
| 867 | 534 | List<AffiliatedOrgInfo> dtos = new ArrayList<AffiliatedOrgInfo>(); |
| 868 | 534 | if (entities != null) { |
| 869 | 532 | for (AffiliatedOrg record : entities) { |
| 870 | 464 | dtos.add(toAffiliatedOrgInfo(record)); |
| 871 | |
} |
| 872 | |
} |
| 873 | 534 | return dtos; |
| 874 | |
} |
| 875 | |
|
| 876 | |
private static AffiliatedOrgInfo toAffiliatedOrgInfo(AffiliatedOrg entity) { |
| 877 | 464 | if (entity == null) { |
| 878 | 0 | return null; |
| 879 | |
} |
| 880 | |
|
| 881 | 464 | AffiliatedOrgInfo dto = new AffiliatedOrgInfo(); |
| 882 | |
|
| 883 | 464 | BeanUtils.copyProperties(entity, dto); |
| 884 | 464 | return dto; |
| 885 | |
} |
| 886 | |
|
| 887 | |
public static CluAccountingInfo toCluAccountingInfo(CluAccounting entity) { |
| 888 | 708 | if (entity == null) { |
| 889 | 527 | return null; |
| 890 | |
} |
| 891 | 181 | CluAccountingInfo dto = new CluAccountingInfo(); |
| 892 | 181 | dto.setId(entity.getId()); |
| 893 | 181 | dto.setAffiliatedOrgs(toAffiliatedOrgInfos(entity.getAffiliatedOrgs())); |
| 894 | 181 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 895 | 181 | return dto; |
| 896 | |
} |
| 897 | |
|
| 898 | |
public static Amount toAmount(AmountInfo amountInfo) { |
| 899 | 121 | if (amountInfo == null) { |
| 900 | 0 | return null; |
| 901 | |
} |
| 902 | 121 | Amount amount = new Amount(); |
| 903 | 121 | BeanUtils.copyProperties(amountInfo, amount); |
| 904 | 121 | return amount; |
| 905 | |
} |
| 906 | |
|
| 907 | |
public static TimeAmount toTimeAmount(TimeAmountInfo timeAmountInfo) { |
| 908 | 121 | if (timeAmountInfo == null) { |
| 909 | 0 | return null; |
| 910 | |
} |
| 911 | 121 | TimeAmount timeAmount = new TimeAmount(); |
| 912 | 121 | BeanUtils.copyProperties(timeAmountInfo, timeAmount); |
| 913 | 121 | return timeAmount; |
| 914 | |
} |
| 915 | |
|
| 916 | |
public static CluCredit toCluCredit(CluCreditInfo cluCreditInfo) { |
| 917 | 0 | if (cluCreditInfo == null) { |
| 918 | 0 | return null; |
| 919 | |
} |
| 920 | 0 | CluCredit cluCredit = new CluCredit(); |
| 921 | |
|
| 922 | 0 | cluCredit.setMaxAllowableInactivity(LuServiceAssembler |
| 923 | |
.toTimeAmount(cluCreditInfo.getMaxAllowableInactivity())); |
| 924 | 0 | cluCredit.setMaxTimeResultsRecognized(LuServiceAssembler |
| 925 | |
.toTimeAmount(cluCreditInfo.getMaxTimeResultsRecognized())); |
| 926 | 0 | cluCredit.setMaxTimeToComplete(LuServiceAssembler |
| 927 | |
.toTimeAmount(cluCreditInfo.getMaxTimeToComplete())); |
| 928 | 0 | cluCredit.setMinTimeToComplete(LuServiceAssembler |
| 929 | |
.toTimeAmount(cluCreditInfo.getMinTimeToComplete())); |
| 930 | 0 | cluCredit.setRepeatTime(LuServiceAssembler.toTimeAmount(cluCreditInfo |
| 931 | |
.getRepeatTime())); |
| 932 | |
|
| 933 | 0 | BeanUtils.copyProperties(cluCreditInfo, cluCredit, new String[] { |
| 934 | |
"repeatTime", "minTimeToComplete", "maxTimeToComplete", |
| 935 | |
"maxAllowableInactivity", "maxTimeResultsRecognized" }); |
| 936 | |
|
| 937 | 0 | return cluCredit; |
| 938 | |
} |
| 939 | |
|
| 940 | |
public static void copyCluCredit(CluCreditInfo cluCreditInfo, |
| 941 | |
CluCredit entity) { |
| 942 | 0 | if (entity == null) { |
| 943 | 0 | return; |
| 944 | |
} |
| 945 | 0 | if (entity.getMaxAllowableInactivity() == null) { |
| 946 | 0 | entity.setMaxAllowableInactivity(new TimeAmount()); |
| 947 | |
} |
| 948 | 0 | BeanUtils.copyProperties(cluCreditInfo.getMaxAllowableInactivity(), |
| 949 | |
entity.getMaxAllowableInactivity()); |
| 950 | |
|
| 951 | 0 | if (entity.getMaxTimeResultsRecognized() == null) { |
| 952 | 0 | entity.setMaxTimeResultsRecognized(new TimeAmount()); |
| 953 | |
} |
| 954 | 0 | BeanUtils.copyProperties(cluCreditInfo.getMaxTimeResultsRecognized(), |
| 955 | |
entity.getMaxTimeResultsRecognized()); |
| 956 | |
|
| 957 | 0 | if (entity.getMaxTimeToComplete() == null) { |
| 958 | 0 | entity.setMaxTimeToComplete(new TimeAmount()); |
| 959 | |
} |
| 960 | 0 | BeanUtils.copyProperties(cluCreditInfo.getMaxTimeToComplete(), entity |
| 961 | |
.getMaxTimeToComplete()); |
| 962 | |
|
| 963 | 0 | if (entity.getMinTimeToComplete() == null) { |
| 964 | 0 | entity.setMinTimeToComplete(new TimeAmount()); |
| 965 | |
} |
| 966 | 0 | BeanUtils.copyProperties(cluCreditInfo.getMinTimeToComplete(), entity |
| 967 | |
.getMinTimeToComplete()); |
| 968 | |
|
| 969 | 0 | if (entity.getRepeatTime() == null) { |
| 970 | 0 | entity.setRepeatTime(new TimeAmount()); |
| 971 | |
} |
| 972 | 0 | BeanUtils.copyProperties(cluCreditInfo.getRepeatTime(), entity |
| 973 | |
.getRepeatTime()); |
| 974 | |
|
| 975 | 0 | BeanUtils.copyProperties(cluCreditInfo, entity, new String[] { |
| 976 | |
"repeatTime", "minTimeToComplete", "maxTimeToComplete", |
| 977 | |
"maxAllowableInactivity", "maxTimeResultsRecognized" }); |
| 978 | |
|
| 979 | 0 | } |
| 980 | |
|
| 981 | |
public static List<AccreditationInfo> toAccreditationInfos( |
| 982 | |
List<CluAccreditation> entities) { |
| 983 | 708 | List<AccreditationInfo> dtos = new ArrayList<AccreditationInfo>(entities.size()); |
| 984 | |
|
| 985 | 708 | if (entities != null) { |
| 986 | 708 | for (CluAccreditation entity : entities) { |
| 987 | 74 | dtos.add(toAccreditationInfo(entity)); |
| 988 | |
} |
| 989 | |
} |
| 990 | 708 | return dtos; |
| 991 | |
} |
| 992 | |
|
| 993 | |
public static AccreditationInfo toAccreditationInfo(CluAccreditation entity) { |
| 994 | 74 | if (entity == null) { |
| 995 | 0 | return null; |
| 996 | |
} |
| 997 | 74 | AccreditationInfo dto = new AccreditationInfo(); |
| 998 | |
|
| 999 | 74 | BeanUtils.copyProperties(entity, dto, new String[] { "attributes" }); |
| 1000 | |
|
| 1001 | 74 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 1002 | |
|
| 1003 | 74 | return dto; |
| 1004 | |
|
| 1005 | |
} |
| 1006 | |
|
| 1007 | |
public static List<AdminOrgInfo> toCluAdminOrgInfos( |
| 1008 | |
List<CluAdminOrg> entities) { |
| 1009 | 708 | List<AdminOrgInfo> dtos = new ArrayList<AdminOrgInfo>(entities.size()); |
| 1010 | 708 | if (entities != null) { |
| 1011 | 708 | for (CluAdminOrg entity : entities) { |
| 1012 | 2422 | dtos.add(toAdminOrgInfo(entity)); |
| 1013 | |
} |
| 1014 | |
} |
| 1015 | 708 | return dtos; |
| 1016 | |
} |
| 1017 | |
|
| 1018 | |
public static AdminOrgInfo toAdminOrgInfo(CluAdminOrg entity) { |
| 1019 | 2422 | if (entity == null) { |
| 1020 | 0 | return null; |
| 1021 | |
} |
| 1022 | 2422 | AdminOrgInfo dto = new AdminOrgInfo(); |
| 1023 | 2422 | BeanUtils.copyProperties(entity, dto, new String[] { "attributes" }); |
| 1024 | 2422 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 1025 | |
|
| 1026 | 2422 | return dto; |
| 1027 | |
} |
| 1028 | |
|
| 1029 | |
public static List<LuPublicationTypeInfo> toLuPublicationTypeInfos( |
| 1030 | |
List<LuPublicationType> entities) { |
| 1031 | 0 | return toGenericTypeInfoList(LuPublicationTypeInfo.class, entities); |
| 1032 | |
} |
| 1033 | |
|
| 1034 | |
public static LuPublicationTypeInfo toLuPublicationTypeInfo( |
| 1035 | |
LuPublicationType entity) { |
| 1036 | 0 | return toGenericTypeInfo(LuPublicationTypeInfo.class, entity); |
| 1037 | |
} |
| 1038 | |
|
| 1039 | |
public static CluFee toCluFee(Clu clu, boolean isUpdate, CluFeeInfo feeInfo, |
| 1040 | |
LuDao dao) throws DoesNotExistException, VersionMismatchException, |
| 1041 | |
InvalidParameterException { |
| 1042 | 35 | if (feeInfo == null) { |
| 1043 | 0 | return null; |
| 1044 | |
} |
| 1045 | |
|
| 1046 | 35 | CluFee fee = null; |
| 1047 | |
|
| 1048 | 35 | if (isUpdate) { |
| 1049 | 10 | fee = clu.getFee(); |
| 1050 | 10 | if (!String.valueOf(fee.getVersionNumber()).equals( |
| 1051 | |
feeInfo.getMetaInfo().getVersionInd())) { |
| 1052 | 0 | throw new VersionMismatchException( |
| 1053 | |
"CluFee to be updated is not the current version"); |
| 1054 | |
} |
| 1055 | |
} |
| 1056 | 35 | if(fee == null){ |
| 1057 | 25 | fee = new CluFee(); |
| 1058 | |
} |
| 1059 | |
|
| 1060 | 35 | if (feeInfo.getDescr() != null && (feeInfo.getDescr().getPlain() != null || feeInfo.getDescr().getFormatted() != null)) { |
| 1061 | 35 | if (fee.getDescr() == null) { |
| 1062 | 25 | fee.setDescr(new LuRichText()); |
| 1063 | |
} |
| 1064 | 35 | BeanUtils.copyProperties(feeInfo.getDescr(), fee.getDescr()); |
| 1065 | 0 | } else if (isUpdate && fee.getDescr() != null) { |
| 1066 | 0 | dao.delete(fee.getDescr()); |
| 1067 | 0 | fee.setDescr(null); |
| 1068 | |
} |
| 1069 | |
|
| 1070 | 35 | fee.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1071 | |
CluFeeAttribute.class, feeInfo.getAttributes(), fee, dao)); |
| 1072 | 35 | toCluFeeRecords(isUpdate, fee, feeInfo.getCluFeeRecords(), dao); |
| 1073 | |
|
| 1074 | 35 | return fee; |
| 1075 | |
} |
| 1076 | |
|
| 1077 | |
public static void toCluFeeRecords(boolean isUpdate, |
| 1078 | |
CluFee cluFee, List<CluFeeRecordInfo> cluFeeRecords, LuDao dao) throws InvalidParameterException { |
| 1079 | |
|
| 1080 | 35 | if (cluFeeRecords == null) { |
| 1081 | 0 | return; |
| 1082 | |
} |
| 1083 | |
|
| 1084 | 35 | if (!isUpdate) { |
| 1085 | |
|
| 1086 | 25 | for (CluFeeRecordInfo feeRecordInfo : cluFeeRecords) { |
| 1087 | 92 | CluFeeRecord feeRec = new CluFeeRecord(); |
| 1088 | 92 | feeRec.setAffiliatedOrgs(toAffiliatedOrgs(isUpdate, feeRec.getAffiliatedOrgs(), feeRecordInfo.getAffiliatedOrgs(), dao)); |
| 1089 | 92 | feeRec.setFeeType(feeRecordInfo.getFeeType()); |
| 1090 | 92 | feeRec.setRateType(feeRecordInfo.getRateType()); |
| 1091 | 92 | feeRec.setDescr(toRichText(LuRichText.class, feeRecordInfo.getDescr())); |
| 1092 | 92 | feeRec.setFeeAmounts(toFeeAmounts(isUpdate, feeRec.getFeeAmounts(), feeRecordInfo.getFeeAmounts(), dao)); |
| 1093 | 92 | feeRec.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1094 | |
CluFeeRecordAttribute.class, feeRecordInfo |
| 1095 | |
.getAttributes(), feeRec, dao)); |
| 1096 | 92 | if(cluFee.getCluFeeRecords()==null){ |
| 1097 | 25 | cluFee.setCluFeeRecords(new ArrayList<CluFeeRecord>()); |
| 1098 | |
} |
| 1099 | 92 | cluFee.getCluFeeRecords().add(feeRec); |
| 1100 | 92 | } |
| 1101 | |
} else { |
| 1102 | 10 | Map<String, CluFeeRecord> oldFeeRecMap = new HashMap<String, CluFeeRecord>(); |
| 1103 | 10 | if(cluFee.getCluFeeRecords()!=null){ |
| 1104 | 10 | for (CluFeeRecord feeRec : cluFee.getCluFeeRecords()) { |
| 1105 | 38 | oldFeeRecMap.put(feeRec.getId(), feeRec); |
| 1106 | |
} |
| 1107 | 10 | cluFee.getCluFeeRecords().clear(); |
| 1108 | |
} |
| 1109 | |
|
| 1110 | |
|
| 1111 | |
|
| 1112 | |
|
| 1113 | 10 | for (CluFeeRecordInfo feeRecordInfo : cluFeeRecords) { |
| 1114 | 37 | CluFeeRecord feeRec = oldFeeRecMap.remove(feeRecordInfo.getId()); |
| 1115 | 37 | if (feeRec == null) { |
| 1116 | 1 | feeRec = new CluFeeRecord(); |
| 1117 | |
} |
| 1118 | |
|
| 1119 | 37 | feeRec.setAffiliatedOrgs(toAffiliatedOrgs(isUpdate, feeRec.getAffiliatedOrgs(), feeRecordInfo.getAffiliatedOrgs(),dao)); |
| 1120 | 37 | feeRec.setFeeType(feeRecordInfo.getFeeType()); |
| 1121 | 37 | feeRec.setRateType(feeRecordInfo.getRateType()); |
| 1122 | 37 | feeRec.setDescr(toRichText(LuRichText.class, feeRecordInfo.getDescr())); |
| 1123 | 37 | feeRec.setFeeAmounts(toFeeAmounts(isUpdate, feeRec.getFeeAmounts(), feeRecordInfo.getFeeAmounts(),dao)); |
| 1124 | 37 | feeRec.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1125 | |
CluFeeRecordAttribute.class, feeRecordInfo |
| 1126 | |
.getAttributes(), feeRec, dao)); |
| 1127 | 37 | if(cluFee.getCluFeeRecords()==null){ |
| 1128 | 0 | cluFee.setCluFeeRecords(new ArrayList<CluFeeRecord>()); |
| 1129 | |
} |
| 1130 | 37 | cluFee.getCluFeeRecords().add(feeRec); |
| 1131 | 37 | } |
| 1132 | |
|
| 1133 | |
|
| 1134 | 10 | for (Entry<String, CluFeeRecord> entry : oldFeeRecMap.entrySet()) { |
| 1135 | 2 | dao.delete(entry.getValue()); |
| 1136 | |
} |
| 1137 | |
} |
| 1138 | 35 | } |
| 1139 | |
|
| 1140 | |
public static List<AffiliatedOrg> toAffiliatedOrgs(boolean isUpdate, List<AffiliatedOrg> orgList, List<AffiliatedOrgInfo> affiliatedOrgInfoList, LuDao dao) { |
| 1141 | 164 | if(null == affiliatedOrgInfoList) { |
| 1142 | 3 | return orgList; |
| 1143 | |
} |
| 1144 | 161 | if(orgList==null){ |
| 1145 | 116 | orgList = new ArrayList<AffiliatedOrg>(); |
| 1146 | |
} |
| 1147 | |
|
| 1148 | 161 | if (!isUpdate) { |
| 1149 | |
|
| 1150 | 115 | for (AffiliatedOrgInfo orgInfo : affiliatedOrgInfoList) { |
| 1151 | 142 | AffiliatedOrg org = new AffiliatedOrg(); |
| 1152 | 142 | BeanUtils.copyProperties(orgInfo, org); |
| 1153 | 142 | orgList.add(org); |
| 1154 | 142 | } |
| 1155 | |
} else { |
| 1156 | 46 | Map<String, AffiliatedOrg> oldOrgMap = new HashMap<String, AffiliatedOrg>(); |
| 1157 | 46 | for (AffiliatedOrg org : orgList) { |
| 1158 | 58 | oldOrgMap.put(org.getId(), org); |
| 1159 | |
} |
| 1160 | 46 | orgList.clear(); |
| 1161 | |
|
| 1162 | 46 | for (AffiliatedOrgInfo orgInfo : affiliatedOrgInfoList) { |
| 1163 | 56 | AffiliatedOrg org = oldOrgMap.remove(orgInfo.getId()); |
| 1164 | 56 | if (org == null) { |
| 1165 | 1 | org = new AffiliatedOrg(); |
| 1166 | |
} |
| 1167 | |
|
| 1168 | 56 | BeanUtils.copyProperties(orgInfo, org); |
| 1169 | |
|
| 1170 | 56 | orgList.add(org); |
| 1171 | 56 | } |
| 1172 | |
|
| 1173 | |
|
| 1174 | 46 | for (Entry<String, AffiliatedOrg> entry : oldOrgMap.entrySet()) { |
| 1175 | 3 | dao.delete(entry.getValue()); |
| 1176 | |
} |
| 1177 | |
} |
| 1178 | |
|
| 1179 | 161 | return orgList; |
| 1180 | |
} |
| 1181 | |
|
| 1182 | |
public static List<CluFeeAmount> toFeeAmounts(boolean isUpdate, List<CluFeeAmount> caList, List<CurrencyAmountInfo> caInfoList, LuDao dao){ |
| 1183 | 129 | if(null == caInfoList) { |
| 1184 | 0 | return caList; |
| 1185 | |
} |
| 1186 | 129 | if(caList==null){ |
| 1187 | 93 | caList = new ArrayList<CluFeeAmount>(caInfoList.size()); |
| 1188 | |
} |
| 1189 | |
|
| 1190 | 129 | if (!isUpdate) { |
| 1191 | 92 | for (CurrencyAmountInfo caInfo:caInfoList){ |
| 1192 | 96 | CurrencyAmount ca = new CurrencyAmount(); |
| 1193 | 96 | ca.setCurrencyQuantity(caInfo.getCurrencyQuantity()); |
| 1194 | 96 | ca.setCurrencyTypeKey(caInfo.getCurrencyTypeKey()); |
| 1195 | 96 | CluFeeAmount cluFeeAmount = new CluFeeAmount(); |
| 1196 | 96 | cluFeeAmount.setCurrencyAmount(ca); |
| 1197 | 96 | caList.add(cluFeeAmount); |
| 1198 | 96 | } |
| 1199 | |
} else { |
| 1200 | |
|
| 1201 | 37 | for (CluFeeAmount cluFeeAmount:caList) { |
| 1202 | 35 | dao.delete(cluFeeAmount); |
| 1203 | |
} |
| 1204 | 37 | caList.clear(); |
| 1205 | |
|
| 1206 | 37 | for (CurrencyAmountInfo caInfo : caInfoList) { |
| 1207 | 36 | CurrencyAmount ca = new CurrencyAmount(); |
| 1208 | |
|
| 1209 | 36 | ca.setCurrencyQuantity(caInfo.getCurrencyQuantity()); |
| 1210 | 36 | ca.setCurrencyTypeKey(caInfo.getCurrencyTypeKey()); |
| 1211 | 36 | CluFeeAmount cluFeeAmount = new CluFeeAmount(); |
| 1212 | 36 | cluFeeAmount.setCurrencyAmount(ca); |
| 1213 | 36 | caList.add(cluFeeAmount); |
| 1214 | 36 | } |
| 1215 | |
} |
| 1216 | |
|
| 1217 | 129 | return caList; |
| 1218 | |
} |
| 1219 | |
|
| 1220 | |
public static CluIdentifier createOfficialIdentifier(CluInfo cluInfo) { |
| 1221 | 56 | CluIdentifier officialIdentifier = new CluIdentifier(); |
| 1222 | 56 | BeanUtils.copyProperties(cluInfo.getOfficialIdentifier(), |
| 1223 | |
officialIdentifier); |
| 1224 | 56 | return officialIdentifier; |
| 1225 | |
} |
| 1226 | |
|
| 1227 | |
public static void updateOfficialIdentifier(Clu clu, CluInfo cluInfo) { |
| 1228 | 46 | if (clu.getOfficialIdentifier() == null) { |
| 1229 | 0 | clu.setOfficialIdentifier(new CluIdentifier()); |
| 1230 | |
} |
| 1231 | 46 | BeanUtils.copyProperties(cluInfo.getOfficialIdentifier(), clu |
| 1232 | |
.getOfficialIdentifier(), new String[] { "id" }); |
| 1233 | 46 | } |
| 1234 | |
|
| 1235 | |
public static List<CluIdentifier> createAlternateIdentifiers(CluInfo cluInfo) { |
| 1236 | 182 | List<CluIdentifier> alternateIdentifiers = new ArrayList<CluIdentifier>(0); |
| 1237 | 182 | for (CluIdentifierInfo cluIdInfo : cluInfo.getAlternateIdentifiers()) { |
| 1238 | 91 | CluIdentifier identifier = new CluIdentifier(); |
| 1239 | 91 | BeanUtils.copyProperties(cluIdInfo, identifier); |
| 1240 | |
|
| 1241 | 91 | alternateIdentifiers.add(identifier); |
| 1242 | 91 | } |
| 1243 | 182 | return alternateIdentifiers; |
| 1244 | |
} |
| 1245 | |
|
| 1246 | |
public static void updateAlternateIdentifier(Map<String, CluIdentifier> oldAltIdMap, Clu clu, CluInfo cluInfo) { |
| 1247 | 48 | for (CluIdentifier altIdentifier : clu.getAlternateIdentifiers()) { |
| 1248 | 79 | oldAltIdMap.put(altIdentifier.getId(), altIdentifier); |
| 1249 | |
} |
| 1250 | 48 | clu.getAlternateIdentifiers().clear(); |
| 1251 | |
|
| 1252 | |
|
| 1253 | |
|
| 1254 | |
|
| 1255 | 48 | for (CluIdentifierInfo cluIdInfo : cluInfo.getAlternateIdentifiers()) { |
| 1256 | 79 | CluIdentifier identifier = oldAltIdMap.remove(cluIdInfo.getId()); |
| 1257 | 79 | if (identifier == null) { |
| 1258 | 1 | identifier = new CluIdentifier(); |
| 1259 | |
} |
| 1260 | |
|
| 1261 | 79 | BeanUtils.copyProperties(cluIdInfo, identifier); |
| 1262 | 79 | clu.getAlternateIdentifiers().add(identifier); |
| 1263 | 79 | } |
| 1264 | 48 | } |
| 1265 | |
|
| 1266 | |
public static List<CluPublicationVariant> toCluPublicationVariants( |
| 1267 | |
List<FieldInfo> variantInfos, CluPublication cluPub, LuDao luDao) { |
| 1268 | 58 | List<CluPublicationVariant> variants = new ArrayList<CluPublicationVariant>(); |
| 1269 | |
|
| 1270 | 58 | if(cluPub.getVariants()==null){ |
| 1271 | 58 | cluPub.setVariants(new ArrayList<CluPublicationVariant>()); |
| 1272 | |
} |
| 1273 | |
|
| 1274 | |
|
| 1275 | 58 | for (CluPublicationVariant variant : cluPub.getVariants()) { |
| 1276 | 0 | luDao.delete(variant); |
| 1277 | |
} |
| 1278 | 58 | cluPub.getVariants().clear(); |
| 1279 | |
|
| 1280 | 58 | for (FieldInfo variantInfo: variantInfos) { |
| 1281 | 30 | CluPublicationVariant variant = new CluPublicationVariant(); |
| 1282 | 30 | variant.setKey(variantInfo.getId()); |
| 1283 | 30 | variant.setValue(variantInfo.getValue()); |
| 1284 | 30 | variant.setOwner(cluPub); |
| 1285 | 30 | variants.add(variant); |
| 1286 | 30 | } |
| 1287 | |
|
| 1288 | 58 | return variants; |
| 1289 | |
} |
| 1290 | |
|
| 1291 | |
public static CluPublicationInfo toCluPublicationInfo(CluPublication cluPub) { |
| 1292 | 247 | if(cluPub==null){ |
| 1293 | 0 | return null; |
| 1294 | |
} |
| 1295 | 247 | CluPublicationInfo cluPubInfo = new CluPublicationInfo(); |
| 1296 | 247 | cluPubInfo.setCluId(cluPub.getClu().getId()); |
| 1297 | 247 | cluPubInfo.setId(cluPub.getId()); |
| 1298 | 247 | cluPubInfo.setEndCycle(cluPub.getEndCycle()); |
| 1299 | 247 | cluPubInfo.setStartCycle(cluPub.getStartCycle()); |
| 1300 | 247 | cluPubInfo.setEffectiveDate(cluPub.getEffectiveDate()); |
| 1301 | 247 | cluPubInfo.setExpirationDate(cluPub.getExpirationDate()); |
| 1302 | 247 | cluPubInfo.setState(cluPub.getState()); |
| 1303 | 247 | cluPubInfo.setType(cluPub.getType().getId()); |
| 1304 | 247 | cluPubInfo.setMetaInfo(toMetaInfo(cluPub.getMeta(), cluPub.getVersionNumber())); |
| 1305 | 247 | cluPubInfo.setAttributes(LuServiceAssembler.toAttributeMap(cluPub.getAttributes())); |
| 1306 | 247 | cluPubInfo.setVariants(LuServiceAssembler.toCluPublicationVariantInfos(cluPub.getVariants())); |
| 1307 | |
|
| 1308 | 247 | return cluPubInfo; |
| 1309 | |
} |
| 1310 | |
|
| 1311 | |
private static List<FieldInfo> toCluPublicationVariantInfos( |
| 1312 | |
List<CluPublicationVariant> variants) { |
| 1313 | 247 | if(variants == null){ |
| 1314 | 0 | return new ArrayList<FieldInfo>(0); |
| 1315 | |
} |
| 1316 | 247 | List<FieldInfo> fields = new ArrayList<FieldInfo>(); |
| 1317 | 247 | for(CluPublicationVariant variant:variants){ |
| 1318 | 172 | FieldInfo field = new FieldInfo(); |
| 1319 | 172 | field.setId(variant.getKey()); |
| 1320 | 172 | field.setValue(variant.getValue()); |
| 1321 | 172 | fields.add(field); |
| 1322 | 172 | } |
| 1323 | 247 | return fields; |
| 1324 | |
} |
| 1325 | |
|
| 1326 | |
public static List<CluPublicationInfo> toCluPublicationInfos( |
| 1327 | |
List<CluPublication> cluPublications) { |
| 1328 | 186 | if(cluPublications == null){ |
| 1329 | 0 | return new ArrayList<CluPublicationInfo>(0); |
| 1330 | |
} |
| 1331 | 186 | List<CluPublicationInfo> cluPublicationInfos = new ArrayList<CluPublicationInfo>(cluPublications.size()); |
| 1332 | 186 | for(CluPublication cluPublication:cluPublications){ |
| 1333 | 168 | cluPublicationInfos.add(toCluPublicationInfo(cluPublication)); |
| 1334 | |
} |
| 1335 | 186 | return cluPublicationInfos; |
| 1336 | |
} |
| 1337 | |
} |