001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.dynamicdatalists.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.language.LanguageUtil;
020    import com.liferay.portal.kernel.log.Log;
021    import com.liferay.portal.kernel.log.LogFactoryUtil;
022    import com.liferay.portal.kernel.search.Hits;
023    import com.liferay.portal.kernel.search.Indexer;
024    import com.liferay.portal.kernel.search.IndexerRegistryUtil;
025    import com.liferay.portal.kernel.search.SearchContext;
026    import com.liferay.portal.kernel.util.ContentTypes;
027    import com.liferay.portal.kernel.util.GetterUtil;
028    import com.liferay.portal.kernel.util.ListUtil;
029    import com.liferay.portal.kernel.util.OrderByComparator;
030    import com.liferay.portal.kernel.util.StringPool;
031    import com.liferay.portal.kernel.util.StringUtil;
032    import com.liferay.portal.kernel.util.Validator;
033    import com.liferay.portal.kernel.workflow.WorkflowConstants;
034    import com.liferay.portal.kernel.workflow.WorkflowHandlerRegistryUtil;
035    import com.liferay.portal.model.CompanyConstants;
036    import com.liferay.portal.model.User;
037    import com.liferay.portal.service.ServiceContext;
038    import com.liferay.portlet.documentlibrary.NoSuchDirectoryException;
039    import com.liferay.portlet.documentlibrary.store.DLStoreUtil;
040    import com.liferay.portlet.documentlibrary.util.DLUtil;
041    import com.liferay.portlet.dynamicdatalists.NoSuchRecordVersionException;
042    import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
043    import com.liferay.portlet.dynamicdatalists.model.DDLRecordConstants;
044    import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
045    import com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion;
046    import com.liferay.portlet.dynamicdatalists.service.base.DDLRecordLocalServiceBaseImpl;
047    import com.liferay.portlet.dynamicdatalists.util.comparator.DDLRecordVersionVersionComparator;
048    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
049    import com.liferay.portlet.dynamicdatamapping.storage.Field;
050    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
051    import com.liferay.portlet.dynamicdatamapping.storage.StorageEngineUtil;
052    import com.liferay.portlet.dynamicdatamapping.util.DDMUtil;
053    
054    import java.io.Serializable;
055    
056    import java.util.Collections;
057    import java.util.Date;
058    import java.util.List;
059    import java.util.Locale;
060    import java.util.Map;
061    
062    /**
063     * @author Marcellus Tavares
064     * @author Eduardo Lundgren
065     */
066    public class DDLRecordLocalServiceImpl extends DDLRecordLocalServiceBaseImpl {
067    
068            public DDLRecord addRecord(
069                            long userId, long groupId, long recordSetId, int displayIndex,
070                            Fields fields, ServiceContext serviceContext)
071                    throws PortalException, SystemException {
072    
073                    // Record
074    
075                    User user = userPersistence.findByPrimaryKey(userId);
076                    Date now = new Date();
077    
078                    DDLRecordSet recordSet = ddlRecordSetPersistence.findByPrimaryKey(
079                            recordSetId);
080    
081                    long recordId = counterLocalService.increment();
082    
083                    DDLRecord record = ddlRecordPersistence.create(recordId);
084    
085                    record.setUuid(serviceContext.getUuid());
086                    record.setGroupId(groupId);
087                    record.setCompanyId(user.getCompanyId());
088                    record.setUserId(user.getUserId());
089                    record.setUserName(user.getFullName());
090                    record.setVersionUserId(user.getUserId());
091                    record.setVersionUserName(user.getFullName());
092                    record.setCreateDate(serviceContext.getCreateDate(now));
093                    record.setModifiedDate(serviceContext.getModifiedDate(now));
094    
095                    long ddmStorageId = StorageEngineUtil.create(
096                            recordSet.getCompanyId(), recordSet.getDDMStructureId(), fields,
097                            serviceContext);
098    
099                    record.setDDMStorageId(ddmStorageId);
100    
101                    record.setRecordSetId(recordSetId);
102                    record.setVersion(DDLRecordConstants.VERSION_DEFAULT);
103                    record.setDisplayIndex(displayIndex);
104    
105                    ddlRecordPersistence.update(record);
106    
107                    // Record version
108    
109                    DDLRecordVersion recordVersion = addRecordVersion(
110                            user, record, ddmStorageId, DDLRecordConstants.VERSION_DEFAULT,
111                            displayIndex, WorkflowConstants.STATUS_DRAFT);
112    
113                    // Asset
114    
115                    Locale locale = serviceContext.getLocale();
116    
117                    updateAsset(
118                            userId, record, recordVersion, serviceContext.getAssetCategoryIds(),
119                            serviceContext.getAssetTagNames(), locale);
120    
121                    // Workflow
122    
123                    WorkflowHandlerRegistryUtil.startWorkflowInstance(
124                            user.getCompanyId(), groupId, userId, DDLRecord.class.getName(),
125                            recordVersion.getRecordVersionId(), recordVersion, serviceContext);
126    
127                    return record;
128            }
129    
130            public DDLRecord addRecord(
131                            long userId, long groupId, long recordSetId, int displayIndex,
132                            Map<String, Serializable> fieldsMap, ServiceContext serviceContext)
133                    throws PortalException, SystemException {
134    
135                    DDLRecordSet recordSet = ddlRecordSetPersistence.findByPrimaryKey(
136                            recordSetId);
137    
138                    DDMStructure ddmStructure = recordSet.getDDMStructure();
139    
140                    Fields fields = toFields(ddmStructure.getStructureId(), fieldsMap);
141    
142                    return addRecord(
143                            userId, groupId, recordSetId, displayIndex, fields, serviceContext);
144            }
145    
146            public void deleteRecord(DDLRecord record)
147                    throws PortalException, SystemException {
148    
149                    // Record
150    
151                    String dirName = DDMUtil.getFileUploadPath(record);
152    
153                    ddlRecordPersistence.remove(record);
154    
155                    // Record Versions
156    
157                    List<DDLRecordVersion> recordVersions =
158                            ddlRecordVersionPersistence.findByRecordId(record.getRecordId());
159    
160                    for (DDLRecordVersion recordVersion : recordVersions) {
161                            ddlRecordVersionPersistence.remove(recordVersion);
162    
163                            // Dynamic data mapping storage
164    
165                            StorageEngineUtil.deleteByClass(recordVersion.getDDMStorageId());
166    
167                            // Workflow
168    
169                            workflowInstanceLinkLocalService.deleteWorkflowInstanceLinks(
170                                    record.getCompanyId(), record.getGroupId(),
171                                    DDLRecord.class.getName(), recordVersion.getPrimaryKey());
172                    }
173    
174                    // Indexer
175    
176                    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(
177                            DDLRecord.class);
178    
179                    indexer.delete(record);
180    
181                    // Document library
182    
183                    try {
184                            DLStoreUtil.deleteDirectory(
185                                    record.getCompanyId(), CompanyConstants.SYSTEM, dirName);
186                    }
187                    catch (NoSuchDirectoryException nsde) {
188                            if (_log.isDebugEnabled()) {
189                                    _log.debug(nsde.getMessage());
190                            }
191                    }
192            }
193    
194            public void deleteRecord(long recordId)
195                    throws PortalException, SystemException {
196    
197                    DDLRecord record = ddlRecordPersistence.findByPrimaryKey(recordId);
198    
199                    deleteRecord(record);
200            }
201    
202            public void deleteRecords(long recordSetId)
203                    throws PortalException, SystemException {
204    
205                    List<DDLRecord> records = ddlRecordPersistence.findByRecordSetId(
206                            recordSetId);
207    
208                    for (DDLRecord record : records) {
209                            deleteRecord(record);
210                    }
211            }
212    
213            public DDLRecord fetchRecord(long recordId) throws SystemException {
214                    return ddlRecordPersistence.fetchByPrimaryKey(recordId);
215            }
216    
217            public List<DDLRecord> getCompanyRecords(
218                            long companyId, int status, int scope, int start, int end,
219                            OrderByComparator orderByComparator)
220                    throws SystemException {
221    
222                    return ddlRecordFinder.findByC_S_S(
223                            companyId, status, scope, start, end, orderByComparator);
224            }
225    
226            /**
227             * @deprecated {@link #getCompanyRecords(long, int, int, int, int,
228             *             OrderByComparator)}
229             */
230            public List<DDLRecord> getCompanyRecords(
231                            long companyId, int scope, int start, int end,
232                            OrderByComparator orderByComparator)
233                    throws SystemException {
234    
235                    return getCompanyRecords(
236                            companyId, WorkflowConstants.STATUS_ANY, scope, start, end,
237                            orderByComparator);
238            }
239    
240            /**
241             * @deprecated {@link #getCompanyRecordsCount(long, int, int)}
242             */
243            public int getCompanyRecordsCount(long companyId, int scope)
244                    throws SystemException {
245    
246                    return getCompanyRecordsCount(
247                            companyId, WorkflowConstants.STATUS_ANY, scope);
248            }
249    
250            public int getCompanyRecordsCount(long companyId, int status, int scope)
251                    throws SystemException {
252    
253                    return ddlRecordFinder.countByC_S_S(companyId, status, scope);
254            }
255    
256            public DDLRecordVersion getLatestRecordVersion(long recordId)
257                    throws PortalException, SystemException {
258    
259                    List<DDLRecordVersion> recordVersions =
260                            ddlRecordVersionPersistence.findByRecordId(recordId);
261    
262                    if (recordVersions.isEmpty()) {
263                            throw new NoSuchRecordVersionException(
264                                    "No record versions found for recordId " + recordId);
265                    }
266    
267                    recordVersions = ListUtil.copy(recordVersions);
268    
269                    Collections.sort(
270                            recordVersions, new DDLRecordVersionVersionComparator());
271    
272                    return recordVersions.get(0);
273            }
274    
275            public Long[] getMinAndMaxCompanyRecordIds(
276                            long companyId, int status, int scope)
277                    throws SystemException {
278    
279                    return ddlRecordFinder.findByC_S_S_MinAndMax(companyId, status, scope);
280            }
281    
282            public List<DDLRecord> getMinAndMaxCompanyRecords(
283                            long companyId, int status, int scope, long minRecordId,
284                            long maxRecordId)
285                    throws SystemException {
286    
287                    return ddlRecordFinder.findByC_S_S_MinAndMax(
288                            companyId, status, scope, minRecordId, maxRecordId);
289            }
290    
291            public DDLRecord getRecord(long recordId)
292                    throws PortalException, SystemException {
293    
294                    return ddlRecordPersistence.findByPrimaryKey(recordId);
295            }
296    
297            public List<DDLRecord> getRecords(long recordSetId) throws SystemException {
298                    return ddlRecordPersistence.findByRecordSetId(recordSetId);
299            }
300    
301            public List<DDLRecord> getRecords(
302                            long recordSetId, int status, int start, int end,
303                            OrderByComparator orderByComparator)
304                    throws SystemException {
305    
306                    return ddlRecordFinder.findByR_S(
307                            recordSetId, status, start, end, orderByComparator);
308            }
309    
310            public List<DDLRecord> getRecords(long recordSetId, long userId)
311                    throws SystemException {
312    
313                    return ddlRecordPersistence.findByR_U(recordSetId, userId);
314            }
315    
316            public int getRecordsCount(long recordSetId, int status)
317                    throws SystemException {
318    
319                    return ddlRecordFinder.countByR_S(recordSetId, status);
320            }
321    
322            public DDLRecordVersion getRecordVersion(long recordVersionId)
323                    throws PortalException, SystemException {
324    
325                    return ddlRecordVersionPersistence.findByPrimaryKey(recordVersionId);
326            }
327    
328            public DDLRecordVersion getRecordVersion(long recordId, String version)
329                    throws PortalException, SystemException {
330    
331                    return ddlRecordVersionPersistence.findByR_V(recordId, version);
332            }
333    
334            public List<DDLRecordVersion> getRecordVersions(
335                            long recordId, int start, int end,
336                            OrderByComparator orderByComparator)
337                    throws SystemException {
338    
339                    return ddlRecordVersionPersistence.findByRecordId(
340                            recordId, start, end, orderByComparator);
341            }
342    
343            public int getRecordVersionsCount(long recordId) throws SystemException {
344                    return ddlRecordVersionPersistence.countByRecordId(recordId);
345            }
346    
347            public void revertRecordVersion(
348                            long userId, long recordId, String version,
349                            ServiceContext serviceContext)
350                    throws PortalException, SystemException {
351    
352                    DDLRecordVersion recordVersion = getRecordVersion(recordId, version);
353    
354                    if (!recordVersion.isApproved()) {
355                            return;
356                    }
357    
358                    Fields fields = StorageEngineUtil.getFields(
359                            recordVersion.getDDMStorageId());
360    
361                    updateRecord(
362                            userId, recordId, true, recordVersion.getDisplayIndex(), fields,
363                            false, serviceContext);
364            }
365    
366            public Hits search(SearchContext searchContext) throws SystemException {
367                    try {
368                            Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(
369                                    DDLRecord.class);
370    
371                            return indexer.search(searchContext);
372                    }
373                    catch (Exception e) {
374                            throw new SystemException(e);
375                    }
376            }
377    
378            public void updateAsset(
379                            long userId, DDLRecord record, DDLRecordVersion recordVersion,
380                            long[] assetCategoryIds, String[] assetTagNames, Locale locale)
381                    throws PortalException, SystemException {
382    
383                    boolean addDraftAssetEntry = false;
384    
385                    if ((recordVersion != null) && !recordVersion.isApproved()) {
386                            String version = recordVersion.getVersion();
387    
388                            if (!version.equals(DDLRecordConstants.VERSION_DEFAULT)) {
389                                    int approvedRecordVersionsCount =
390                                            ddlRecordVersionPersistence.countByR_S(
391                                                    record.getRecordId(),
392                                                    WorkflowConstants.STATUS_APPROVED);
393    
394                                    if (approvedRecordVersionsCount > 0) {
395                                            addDraftAssetEntry = true;
396                                    }
397                            }
398                    }
399    
400                    boolean visible = false;
401    
402                    if ((recordVersion != null) && !recordVersion.isApproved()) {
403                            visible = false;
404                    }
405    
406                    DDLRecordSet recordSet = record.getRecordSet();
407    
408                    String title = LanguageUtil.format(
409                            locale, "new-record-for-list-x", recordSet.getName(locale));
410    
411                    if (addDraftAssetEntry) {
412                            assetEntryLocalService.updateEntry(
413                                    userId, record.getGroupId(), record.getCreateDate(),
414                                    record.getModifiedDate(), DDLRecordConstants.getClassName(),
415                                    recordVersion.getRecordVersionId(), record.getUuid(), 0,
416                                    assetCategoryIds, assetTagNames, false, null, null, null,
417                                    ContentTypes.TEXT_HTML, title, null, StringPool.BLANK, null,
418                                    null, 0, 0, null, false);
419                    }
420                    else {
421                            assetEntryLocalService.updateEntry(
422                                    userId, record.getGroupId(), record.getCreateDate(),
423                                    record.getModifiedDate(), DDLRecordConstants.getClassName(),
424                                    record.getRecordId(), record.getUuid(), 0, assetCategoryIds,
425                                    assetTagNames, visible, null, null, null,
426                                    ContentTypes.TEXT_HTML, title, null, StringPool.BLANK, null,
427                                    null, 0, 0, null, false);
428                    }
429            }
430    
431            public DDLRecord updateRecord(
432                            long userId, long recordId, boolean majorVersion, int displayIndex,
433                            Fields fields, boolean mergeFields, ServiceContext serviceContext)
434                    throws PortalException, SystemException {
435    
436                    // Record
437    
438                    User user = userPersistence.findByPrimaryKey(userId);
439    
440                    DDLRecord record = ddlRecordPersistence.findByPrimaryKey(recordId);
441    
442                    record.setModifiedDate(serviceContext.getModifiedDate(null));
443    
444                    ddlRecordPersistence.update(record);
445    
446                    // Record version
447    
448                    DDLRecordVersion recordVersion = record.getLatestRecordVersion();
449    
450                    if (recordVersion.isApproved()) {
451                            DDLRecordSet recordSet = record.getRecordSet();
452    
453                            long ddmStorageId = StorageEngineUtil.create(
454                                    recordSet.getCompanyId(), recordSet.getDDMStructureId(), fields,
455                                    serviceContext);
456                            String version = getNextVersion(
457                                    recordVersion.getVersion(), majorVersion,
458                                    serviceContext.getWorkflowAction());
459    
460                            recordVersion = addRecordVersion(
461                                    user, record, ddmStorageId, version, displayIndex,
462                                    WorkflowConstants.STATUS_DRAFT);
463                    }
464                    else {
465                            StorageEngineUtil.update(
466                                    recordVersion.getDDMStorageId(), fields, mergeFields,
467                                    serviceContext);
468    
469                            String version = recordVersion.getVersion();
470    
471                            updateRecordVersion(
472                                    user, recordVersion, version, displayIndex,
473                                    recordVersion.getStatus(), serviceContext);
474                    }
475    
476                    // Workflow
477    
478                    WorkflowHandlerRegistryUtil.startWorkflowInstance(
479                            user.getCompanyId(), record.getGroupId(), userId,
480                            DDLRecord.class.getName(), recordVersion.getRecordVersionId(),
481                            recordVersion, serviceContext);
482    
483                    return record;
484            }
485    
486            public DDLRecord updateRecord(
487                            long userId, long recordId, int displayIndex,
488                            Map<String, Serializable> fieldsMap, boolean mergeFields,
489                            ServiceContext serviceContext)
490                    throws PortalException, SystemException {
491    
492                    DDLRecord record = ddlRecordPersistence.findByPrimaryKey(recordId);
493    
494                    DDLRecordSet recordSet = record.getRecordSet();
495    
496                    DDMStructure ddmStructure = recordSet.getDDMStructure();
497    
498                    Fields fields = toFields(ddmStructure.getStructureId(), fieldsMap);
499    
500                    return updateRecord(
501                            userId, recordId, false, displayIndex, fields, mergeFields,
502                            serviceContext);
503            }
504    
505            public DDLRecord updateStatus(
506                            long userId, long recordVersionId, int status,
507                            ServiceContext serviceContext)
508                    throws PortalException, SystemException {
509    
510                    // Record version
511    
512                    User user = userPersistence.findByPrimaryKey(userId);
513    
514                    DDLRecordVersion recordVersion =
515                            ddlRecordVersionPersistence.findByPrimaryKey(recordVersionId);
516    
517                    recordVersion.setStatus(status);
518                    recordVersion.setStatusByUserId(user.getUserId());
519                    recordVersion.setStatusByUserName(user.getFullName());
520                    recordVersion.setStatusDate(new Date());
521    
522                    ddlRecordVersionPersistence.update(recordVersion);
523    
524                    // Record
525    
526                    DDLRecord record = ddlRecordPersistence.findByPrimaryKey(
527                            recordVersion.getRecordId());
528    
529                    if (status == WorkflowConstants.STATUS_APPROVED) {
530                            if (DLUtil.compareVersions(
531                                            record.getVersion(), recordVersion.getVersion()) <= 0) {
532    
533                                    record.setDDMStorageId(recordVersion.getDDMStorageId());
534                                    record.setVersion(recordVersion.getVersion());
535                                    record.setRecordSetId(recordVersion.getRecordSetId());
536                                    record.setDisplayIndex(recordVersion.getDisplayIndex());
537                                    record.setVersion(recordVersion.getVersion());
538                                    record.setVersionUserId(recordVersion.getUserId());
539                                    record.setVersionUserName(recordVersion.getUserName());
540                                    record.setModifiedDate(recordVersion.getCreateDate());
541    
542                                    ddlRecordPersistence.update(record);
543                            }
544                    }
545                    else {
546                            if (Validator.equals(
547                                            record.getVersion(), recordVersion.getVersion())) {
548    
549                                    String newVersion = DDLRecordConstants.VERSION_DEFAULT;
550    
551                                    List<DDLRecordVersion> approvedRecordVersions =
552                                            ddlRecordVersionPersistence.findByR_S(
553                                                    record.getRecordId(),
554                                                    WorkflowConstants.STATUS_APPROVED);
555    
556                                    if (!approvedRecordVersions.isEmpty()) {
557                                            newVersion = approvedRecordVersions.get(0).getVersion();
558                                    }
559    
560                                    record.setVersion(newVersion);
561    
562                                    ddlRecordPersistence.update(record);
563                            }
564    
565                            // Indexer
566    
567                            if (Validator.equals(
568                                            recordVersion.getVersion(),
569                                            DDLRecordConstants.VERSION_DEFAULT)) {
570    
571                                    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(
572                                            DDLRecord.class);
573    
574                                    indexer.delete(record);
575                            }
576                    }
577    
578                    // Indexer
579    
580                    if (status == WorkflowConstants.STATUS_APPROVED) {
581                            Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(
582                                    DDLRecord.class);
583    
584                            indexer.reindex(record);
585                    }
586    
587                    return record;
588            }
589    
590            protected DDLRecordVersion addRecordVersion(
591                            User user, DDLRecord record, long ddmStorageId, String version,
592                            int displayIndex, int status)
593                    throws SystemException {
594    
595                    long recordVersionId = counterLocalService.increment();
596    
597                    DDLRecordVersion recordVersion = ddlRecordVersionPersistence.create(
598                            recordVersionId);
599    
600                    recordVersion.setGroupId(record.getGroupId());
601                    recordVersion.setCompanyId(record.getCompanyId());
602    
603                    long versionUserId = record.getVersionUserId();
604    
605                    if (versionUserId <= 0) {
606                            versionUserId = record.getUserId();
607                    }
608    
609                    recordVersion.setUserId(versionUserId);
610    
611                    String versionUserName = GetterUtil.getString(
612                            record.getVersionUserName(), record.getUserName());
613    
614                    recordVersion.setUserName(versionUserName);
615    
616                    recordVersion.setCreateDate(record.getModifiedDate());
617                    recordVersion.setDDMStorageId(ddmStorageId);
618                    recordVersion.setRecordSetId(record.getRecordSetId());
619                    recordVersion.setRecordId(record.getRecordId());
620                    recordVersion.setVersion(version);
621                    recordVersion.setDisplayIndex(displayIndex);
622                    recordVersion.setStatus(status);
623                    recordVersion.setStatusByUserId(user.getUserId());
624                    recordVersion.setStatusByUserName(user.getFullName());
625                    recordVersion.setStatusDate(record.getModifiedDate());
626    
627                    ddlRecordVersionPersistence.update(recordVersion);
628    
629                    return recordVersion;
630            }
631    
632            protected String getNextVersion(
633                    String version, boolean majorVersion, int workflowAction) {
634    
635                    if (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT) {
636                            majorVersion = false;
637                    }
638    
639                    int[] versionParts = StringUtil.split(version, StringPool.PERIOD, 0);
640    
641                    if (majorVersion) {
642                            versionParts[0]++;
643                            versionParts[1] = 0;
644                    }
645                    else {
646                            versionParts[1]++;
647                    }
648    
649                    return versionParts[0] + StringPool.PERIOD + versionParts[1];
650            }
651    
652            protected Fields toFields(
653                    long ddmStructureId, Map<String, Serializable> fieldsMap) {
654    
655                    Fields fields = new Fields();
656    
657                    for (String name : fieldsMap.keySet()) {
658                            String value = String.valueOf(fieldsMap.get(name));
659    
660                            Field field = new Field(ddmStructureId, name, value);
661    
662                            fields.put(field);
663                    }
664    
665                    return fields;
666            }
667    
668            protected void updateRecordVersion(
669                            User user, DDLRecordVersion recordVersion, String version,
670                            int displayIndex, int status, ServiceContext serviceContext)
671                    throws SystemException {
672    
673                    recordVersion.setVersion(version);
674                    recordVersion.setDisplayIndex(displayIndex);
675                    recordVersion.setStatus(status);
676                    recordVersion.setStatusByUserId(user.getUserId());
677                    recordVersion.setStatusByUserName(user.getFullName());
678                    recordVersion.setStatusDate(serviceContext.getModifiedDate(null));
679    
680                    ddlRecordVersionPersistence.update(recordVersion);
681            }
682    
683            private static Log _log = LogFactoryUtil.getLog(
684                    DDLRecordLocalServiceImpl.class);
685    
686    }