mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-7098: [Upgrade] Add to Hold and Remove from hold audit events are not properly migrated
This commit is contained in:
committed by
Christopher Shields
parent
013b8bcd18
commit
a3574f7f2b
@@ -19,7 +19,7 @@
|
||||
<property name="nodeService" ref="nodeService" />
|
||||
</bean>
|
||||
|
||||
<bean id="rm.holdHoldReportUpdatePatch"
|
||||
<bean id="rm.holdReportUpdatePatch"
|
||||
parent="rm.parentModulePatch"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.patch.v32.RMv32HoldReportUpdatePatch">
|
||||
<property name="description" value="Update template for generating hold report"/>
|
||||
|
@@ -0,0 +1,19 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<!-- RM v3.3 Patches -->
|
||||
|
||||
<bean id="rm.holdAuditValuesUpdatedPatch"
|
||||
parent="rm.parentModulePatch"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.patch.v33.RMv33HoldAuditEntryValuesPatch">
|
||||
<property name="description"
|
||||
value="Change values for addToHold and removeFromHold audit entries to match updated values for these entries" />
|
||||
<property name="fixesFromSchema" value="2400" />
|
||||
<property name="fixesToSchema" value="3201" />
|
||||
<property name="targetSchema" value="3300" />
|
||||
<property name="recordsManagementQueryDAO" ref="recordsManagementQueryDAO" />
|
||||
</bean>
|
||||
</beans>
|
@@ -83,5 +83,28 @@
|
||||
and alfn.id between ? and ?
|
||||
</select>
|
||||
|
||||
<!-- Get a property string value entity -->
|
||||
<select id="select_PropertyStringValue"
|
||||
parameterType="org.alfresco.repo.domain.propval.PropertyStringValueEntity"
|
||||
resultType="org.alfresco.repo.domain.propval.PropertyStringValueEntity">
|
||||
select id,
|
||||
string_value as stringValue,
|
||||
string_end_lower as stringEndLower,
|
||||
string_crc as stringCrc
|
||||
from alf_prop_string_value
|
||||
where string_value = #{stringValue}
|
||||
and string_end_lower = #{stringEndLower}
|
||||
and string_crc = #{stringCrc}
|
||||
</select>
|
||||
|
||||
<!-- Update a property string value entity -->
|
||||
<update id="update_PropertyStringValue"
|
||||
parameterType="org.alfresco.repo.domain.propval.PropertyStringValueEntity">
|
||||
update alf_prop_string_value
|
||||
set string_value = #{stringValue},
|
||||
string_end_lower = #{stringEndLower},
|
||||
string_crc = #{stringCrc}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=3201
|
||||
version.rm.schema=3300
|
||||
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.patch.v33;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
|
||||
import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO;
|
||||
import org.alfresco.repo.domain.propval.PropertyStringValueEntity;
|
||||
|
||||
/**
|
||||
* Patch to update values for addToHold and removeFromHold event types
|
||||
* <p>
|
||||
* See: https://issues.alfresco.com/jira/browse/RM-7098
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 3.3
|
||||
*/
|
||||
public class RMv33HoldAuditEntryValuesPatch extends AbstractModulePatch
|
||||
{
|
||||
|
||||
/**
|
||||
* Services
|
||||
*/
|
||||
private RecordsManagementQueryDAO recordsManagementQueryDAO;
|
||||
|
||||
public void setRecordsManagementQueryDAO(RecordsManagementQueryDAO recordsManagementQueryDAO)
|
||||
{
|
||||
this.recordsManagementQueryDAO = recordsManagementQueryDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal()
|
||||
*
|
||||
* Updates the property string value entities for addToHold and removeFromHold audit event types
|
||||
*/
|
||||
@Override
|
||||
public void applyInternal()
|
||||
{
|
||||
updatePropertyStringValueEntity("addToHold", "Add To Hold");
|
||||
updatePropertyStringValueEntity("removeFromHold", "Remove From Hold");
|
||||
|
||||
}
|
||||
|
||||
private void updatePropertyStringValueEntity(String fromStringValue, String toStringValue)
|
||||
{
|
||||
PropertyStringValueEntity addToAuditPropertyStringValueEntity = recordsManagementQueryDAO.getPropertyStringValueEntity(fromStringValue);
|
||||
addToAuditPropertyStringValueEntity.setValue(toStringValue);
|
||||
recordsManagementQueryDAO.updatePropertyStringValueEntity(addToAuditPropertyStringValueEntity);
|
||||
}
|
||||
|
||||
}
|
@@ -30,8 +30,8 @@ package org.alfresco.module.org_alfresco_module_rm.query;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.domain.propval.PropertyStringValueEntity;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import java.util.Collection;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
@@ -80,4 +80,16 @@ public interface RecordsManagementQueryDAO
|
||||
* @return Set<NodeRef> a set of nodes that reference the given content url
|
||||
*/
|
||||
Set<NodeRef> getNodeRefsWhichReferenceContentUrl(String contentUrl);
|
||||
|
||||
/**
|
||||
* Get the property string value entity with the specified string value
|
||||
* @return PropertyStringValueEntity the property string value entity with the specified string value
|
||||
*/
|
||||
PropertyStringValueEntity getPropertyStringValueEntity(String stringValue);
|
||||
|
||||
/**
|
||||
* Update the property string value entity
|
||||
* @return int the number of rows updated
|
||||
*/
|
||||
int updatePropertyStringValueEntity(PropertyStringValueEntity propertyStringValueEntity);
|
||||
}
|
||||
|
@@ -29,9 +29,8 @@ package org.alfresco.module.org_alfresco_module_rm.query;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -40,6 +39,7 @@ import java.util.Set;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.domain.contentdata.ContentUrlEntity;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.domain.propval.PropertyStringValueEntity;
|
||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.repo.version.Version2Model;
|
||||
@@ -73,6 +73,8 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
|
||||
private static final String SELECT_NODE_IDS_WHICH_REFERENCE_CONTENT_URL = "select_NodeIdsWhichReferenceContentUrl";
|
||||
private static final String SCHEDULED_FOLDERS = "alfresco.query.rm.select_RecordFoldersWithSchedules";
|
||||
private static final String SCHEDULED_FOLDERS_COUNT = "alfresco.query.rm.select_RecordFoldersWithSchedulesCount";
|
||||
private static final String GET_PROP_STRING_VALUE = "alfresco.query.rm.select_PropertyStringValue";
|
||||
private static final String UPDATE_PROP_STRING_VALUE = "alfresco.query.rm.update_PropertyStringValue";
|
||||
|
||||
/**
|
||||
* SQL session template
|
||||
@@ -284,4 +286,22 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getPropertyStringValueEntity(String stringValue)
|
||||
*/
|
||||
public PropertyStringValueEntity getPropertyStringValueEntity(String stringValue){
|
||||
|
||||
PropertyStringValueEntity propertyStringValueEntity = new PropertyStringValueEntity();
|
||||
propertyStringValueEntity.setValue(stringValue);
|
||||
|
||||
return template.selectOne(GET_PROP_STRING_VALUE, propertyStringValueEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#updatePropertyStringValueEntity(PropertyStringValueEntity propertyStringValueEntity)
|
||||
*/
|
||||
public int updatePropertyStringValueEntity(PropertyStringValueEntity propertyStringValueEntity)
|
||||
{
|
||||
return template.update(UPDATE_PROP_STRING_VALUE, propertyStringValueEntity);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.patch.v33;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO;
|
||||
import org.alfresco.repo.domain.propval.PropertyStringValueEntity;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
/**
|
||||
* RM V3.3 Hold audit entries values patch unit test
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 3.3
|
||||
*/
|
||||
public class RMv33HoldAuditEntryValuesPatchUnitTest
|
||||
{
|
||||
@Mock
|
||||
private RecordsManagementQueryDAO mockedRecordsManagementQueryDAO;
|
||||
|
||||
@InjectMocks
|
||||
private RMv33HoldAuditEntryValuesPatch patch;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* addtohold and removeFromHold audit entries values are updated after the patch is executed
|
||||
*/
|
||||
@Test
|
||||
public void holdAuditEntriesAreUpdatedAfterUpgrade()
|
||||
{
|
||||
PropertyStringValueEntity addToHoldPropertyStringValueEntity = new PropertyStringValueEntity();
|
||||
addToHoldPropertyStringValueEntity.setValue("addToHold");
|
||||
when(mockedRecordsManagementQueryDAO.getPropertyStringValueEntity("addToHold")).thenReturn(addToHoldPropertyStringValueEntity);
|
||||
when(mockedRecordsManagementQueryDAO.updatePropertyStringValueEntity(addToHoldPropertyStringValueEntity)).thenReturn(1);
|
||||
|
||||
PropertyStringValueEntity removeFromHoldPropertyStringValueEntity = new PropertyStringValueEntity();
|
||||
removeFromHoldPropertyStringValueEntity.setValue("removeFromHold");
|
||||
when(mockedRecordsManagementQueryDAO.getPropertyStringValueEntity("removeFromHold")).thenReturn(removeFromHoldPropertyStringValueEntity);
|
||||
when(mockedRecordsManagementQueryDAO.updatePropertyStringValueEntity(removeFromHoldPropertyStringValueEntity)).thenReturn(1);
|
||||
|
||||
patch.applyInternal();
|
||||
|
||||
verify(mockedRecordsManagementQueryDAO, times(1)).getPropertyStringValueEntity("addToHold");
|
||||
verify(mockedRecordsManagementQueryDAO, times(1)).updatePropertyStringValueEntity(addToHoldPropertyStringValueEntity);
|
||||
verify(mockedRecordsManagementQueryDAO, times(1)).getPropertyStringValueEntity("removeFromHold");
|
||||
verify(mockedRecordsManagementQueryDAO, times(1)).updatePropertyStringValueEntity(removeFromHoldPropertyStringValueEntity);
|
||||
|
||||
assertEquals("Add To Hold", addToHoldPropertyStringValueEntity.getStringValue());
|
||||
assertEquals("add to hold", addToHoldPropertyStringValueEntity.getStringEndLower());
|
||||
assertEquals(Long.valueOf(770_786_109L), addToHoldPropertyStringValueEntity.getStringCrc());
|
||||
|
||||
assertEquals("Remove From Hold", removeFromHoldPropertyStringValueEntity.getStringValue());
|
||||
assertEquals("remove from hold", removeFromHoldPropertyStringValueEntity.getStringEndLower());
|
||||
assertEquals(Long.valueOf(2_967_613_012L), removeFromHoldPropertyStringValueEntity.getStringCrc());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user