diff --git a/src/main/java/org/olat/core/commons/persistence/_spring/core_persistence.xml b/src/main/java/org/olat/core/commons/persistence/_spring/core_persistence.xml index 3d6d9d0720535571029ef3c26e41c3b31657d706..8485114184f214191c0ad23fd08f8324f81345ec 100644 --- a/src/main/java/org/olat/core/commons/persistence/_spring/core_persistence.xml +++ b/src/main/java/org/olat/core/commons/persistence/_spring/core_persistence.xml @@ -84,6 +84,7 @@ <mapping-file>org/olat/upgrade/model/BusinessGroupUpgrade.hbm.xml</mapping-file> <mapping-file>org/olat/upgrade/model/BGResourceRelation.hbm.xml</mapping-file> <mapping-file>org/olat/upgrade/model/RepositoryEntryUpgrade.hbm.xml</mapping-file> + <mapping-file>org/olat/upgrade/model/EPMapUpgrade.hbm.xml</mapping-file> <class>org.olat.upgrade.model.RepositoryEntryUpgradeToGroupRelation</class> <!-- End upgraders mapping --> diff --git a/src/main/java/org/olat/upgrade/OLATUpgrade_10_0_0.java b/src/main/java/org/olat/upgrade/OLATUpgrade_10_0_0.java index 47781c0210e82fb796d088eac23510ba51c0b27b..5e2df8a51b056a83b1e7cb2022674073b5331585 100644 --- a/src/main/java/org/olat/upgrade/OLATUpgrade_10_0_0.java +++ b/src/main/java/org/olat/upgrade/OLATUpgrade_10_0_0.java @@ -19,6 +19,7 @@ */ package org.olat.upgrade; +import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; @@ -27,11 +28,14 @@ import java.util.Set; import org.olat.basesecurity.BaseSecurity; import org.olat.basesecurity.Group; import org.olat.basesecurity.GroupRoles; +import org.olat.basesecurity.Policy; import org.olat.basesecurity.SecurityGroup; import org.olat.basesecurity.manager.GroupDAO; import org.olat.core.commons.persistence.DB; import org.olat.core.id.Identity; import org.olat.group.manager.BusinessGroupRelationDAO; +import org.olat.group.right.BGRightManager; +import org.olat.group.right.BGRightsRole; import org.olat.repository.RepositoryManager; import org.olat.repository.manager.RepositoryEntryRelationDAO; import org.olat.resource.OLATResource; @@ -66,6 +70,8 @@ public class OLATUpgrade_10_0_0 extends OLATUpgrade { @Autowired private RepositoryManager repositoryManager; @Autowired + private BGRightManager bgRightManager; + @Autowired private BusinessGroupRelationDAO businessGroupRelationDao; @Autowired private RepositoryEntryRelationDAO repositoryEntryToGroupDAO; @@ -94,11 +100,11 @@ public class OLATUpgrade_10_0_0 extends OLATUpgrade { return false; } - boolean allOk = false; - //allOk &= upgradeBusinessGroups(upgradeManager, uhd); - //allOk &= upgradeRepositoryEntries(upgradeManager, uhd); - //allOk &= upgradeRelationsRepoToBusinessGroups(upgradeManager, uhd); - //allOk &= upgradeEPMap(upgradeManager, uhd); + boolean allOk = true; + allOk &= upgradeBusinessGroups(upgradeManager, uhd); + allOk &= upgradeRepositoryEntries(upgradeManager, uhd); + allOk &= upgradeRelationsRepoToBusinessGroups(upgradeManager, uhd); + allOk &= upgradeEPMap(upgradeManager, uhd); uhd.setInstallationComplete(allOk); upgradeManager.setUpgradesHistory(uhd, VERSION); @@ -107,7 +113,7 @@ public class OLATUpgrade_10_0_0 extends OLATUpgrade { } else { log.audit("OLATUpgrade_10_0_0 not finished, try to restart OpenOLAT!"); } - return false; + return allOk; } private boolean upgradeBusinessGroups(UpgradeManager upgradeManager, UpgradeHistoryData uhd) { @@ -117,21 +123,24 @@ public class OLATUpgrade_10_0_0 extends OLATUpgrade { do { businessGroups = findBusinessGroups(counter, BATCH_SIZE); for(BusinessGroupUpgrade businessGroup:businessGroups) { - processBusinessGroup(businessGroup); + BusinessGroupUpgrade up = processBusinessGroup(businessGroup); + processRightGroup(up); } counter += businessGroups.size(); - log.audit("Business groups processed: " + businessGroups.size() + ", total processed (" + counter + " )"); + log.audit("Business groups processed: " + businessGroups.size() + ", total processed (" + counter + ")"); dbInstance.commitAndCloseSession(); } while(businessGroups.size() == BATCH_SIZE); - uhd.setBooleanDataValue(TASK_BUSINESS_GROUPS, false); + uhd.setBooleanDataValue(TASK_BUSINESS_GROUPS, true); upgradeManager.setUpgradesHistory(uhd, VERSION); } - return false; + return true; } - private void processBusinessGroup(BusinessGroupUpgrade businessGroup) { + private BusinessGroupUpgrade processBusinessGroup(BusinessGroupUpgrade businessGroup) { Group baseGroup = businessGroup.getBaseGroup(); - if(baseGroup != null && baseGroup.getKey() != null) return; + if(baseGroup != null && baseGroup.getKey() != null) { + return businessGroup; + } Group group = groupDao.createGroup(); //update tutors @@ -144,8 +153,42 @@ public class OLATUpgrade_10_0_0 extends OLATUpgrade { dbInstance.commit(); businessGroup.setBaseGroup(group); + businessGroup = dbInstance.getCurrentEntityManager().merge(businessGroup); dbInstance.commit(); + return businessGroup; + } + + private void processRightGroup(BusinessGroupUpgrade businessGroup) { + boolean commit = false; + + List<String> tutorRights = findBGRights(businessGroup.getOwnerGroup()); + for(String right:tutorRights) { + bgRightManager.addBGRight(right, businessGroup, BGRightsRole.tutor); + commit = true; + } + + List<String> participantsRights = findBGRights(businessGroup.getPartipiciantGroup()); + for(String right:participantsRights) { + bgRightManager.addBGRight(right, businessGroup, BGRightsRole.participant); + commit = true; + } + + if(commit) { + dbInstance.commit(); + } + } + + private List<String> findBGRights(SecurityGroup secGroup) { + List<Policy> results = securityManager.getPoliciesOfSecurityGroup(secGroup); + // filter all business group rights permissions. group right permissions + // start with bgr. + List<String> rights = new ArrayList<String>(); + for (Policy rightPolicy:results) { + String right = rightPolicy.getPermission(); + if (right.indexOf("bgr.") == 0) rights.add(right); + } + return rights; } private boolean upgradeRepositoryEntries(UpgradeManager upgradeManager, UpgradeHistoryData uhd) { @@ -158,13 +201,13 @@ public class OLATUpgrade_10_0_0 extends OLATUpgrade { processRepositoryEntry(repoEntry); } counter += repoEntries.size(); - log.audit("Repository entries processed: " + repoEntries.size() + ", total processed (" + counter + " )"); + log.audit("Repository entries processed: " + repoEntries.size() + ", total processed (" + counter + ")"); dbInstance.commitAndCloseSession(); } while(repoEntries.size() == BATCH_SIZE); - uhd.setBooleanDataValue(TASK_REPOENTRIES, false); + uhd.setBooleanDataValue(TASK_REPOENTRIES, true); upgradeManager.setUpgradesHistory(uhd, VERSION); } - return false; + return true; } private void processRepositoryEntry(RepositoryEntryUpgrade repoEntry) { @@ -219,13 +262,13 @@ public class OLATUpgrade_10_0_0 extends OLATUpgrade { processRelationToRepo(businessGroup); } counter += businessGroups.size(); - log.audit("Business groups processed: " + businessGroups.size() + ", total processed (" + counter + " )"); + log.audit("Business groups relations processed: " + businessGroups.size() + ", total processed (" + counter + ")"); dbInstance.commitAndCloseSession(); } while(businessGroups.size() == BATCH_SIZE); - uhd.setBooleanDataValue(TASK_REPOENTRY_TO_BUSINESSGROUP, false); + uhd.setBooleanDataValue(TASK_REPOENTRY_TO_BUSINESSGROUP, true); upgradeManager.setUpgradesHistory(uhd, VERSION); } - return false; + return true; } private void processRelationToRepo(BusinessGroupUpgrade businessGroup) { @@ -278,32 +321,63 @@ public class OLATUpgrade_10_0_0 extends OLATUpgrade { processMap(businessGroup); } counter += businessGroups.size(); - log.audit("Maps processed: " + businessGroups.size() + ", total processed (" + counter + " )"); + log.audit("Maps processed: " + businessGroups.size() + ", total processed (" + counter + ")"); dbInstance.commitAndCloseSession(); } while(businessGroups.size() == BATCH_SIZE); - uhd.setBooleanDataValue(TASK_UPGRADE_MAP, false); + uhd.setBooleanDataValue(TASK_UPGRADE_MAP, true); upgradeManager.setUpgradesHistory(uhd, VERSION); } - return false; + return true; + } + + private void processMap(EPMapUpgrade map) { + if(map.getGroup() != null) return; + + SecurityGroup ownerGroup = map.getOwnerGroup(); + if(ownerGroup != null) { + RepositoryEntryUpgrade re = findMapRepoEntry(ownerGroup); + if(re != null) { + Group reGroup = repositoryEntryToGroupDAO.getDefaultGroup(re); + if(reGroup != null) { + map.setGroup(reGroup); + } + } + if(map.getGroup() == null) { + Group group = groupDao.createGroup(); + map.setGroup(group); + processSecurityGroup(group, GroupRoles.owner.name(), ownerGroup); + } + dbInstance.getCurrentEntityManager().merge(map); + } + } + + private RepositoryEntryUpgrade findMapRepoEntry(SecurityGroup ownerGroup) { + StringBuilder sb = new StringBuilder(); + sb.append("select v from ").append(RepositoryEntryUpgrade.class.getName()).append(" as v") + .append(" where v.ownerGroup=:ownerGroup"); + List<RepositoryEntryUpgrade> res = dbInstance.getCurrentEntityManager() + .createQuery(sb.toString(), RepositoryEntryUpgrade.class) + .setParameter("ownerGroup", ownerGroup) + .getResultList(); + if(res.size() > 0) { + return res.get(0); + } + return null; } private List<EPMapUpgrade> findMaps(int firstResult, int maxResults) { StringBuilder sb = new StringBuilder(); sb.append("select map from ").append(EPMapUpgrade.class.getName()).append(" map") - .append(" left join fetch map.baseGroup as baseGroup") + .append(" left join fetch map.group as baseGroup") .append(" left join fetch map.ownerGroup as ownerGroup") - .append(" where map.baseGroup is null and map.ownerGroup is not null") + .append(" where map.group is null and map.ownerGroup is not null") .append(" order by map.key"); return dbInstance.getCurrentEntityManager().createQuery(sb.toString(), EPMapUpgrade.class) .setFirstResult(firstResult) .setMaxResults(maxResults) .getResultList(); } - - private void processMap(EPMapUpgrade map) { - // - } - + private void processSecurityGroup(Group group, String role, SecurityGroup secGroup) { if(secGroup == null) return; @@ -330,18 +404,22 @@ public class OLATUpgrade_10_0_0 extends OLATUpgrade { private List<RepositoryEntryUpgrade> findRepositoryEntries(int firstResult, int maxResults) { StringBuilder sb = new StringBuilder(); - sb.append("select re from ").append(RepositoryEntryUpgrade.class.getName()).append(" re order by key"); + sb.append("select v from ").append(RepositoryEntryUpgrade.class.getName()).append(" v") + .append(" inner join fetch v.olatResource as ores") + .append(" left join fetch v.ownerGroup as ownerGroup") + .append(" left join fetch v.participantGroup as participantGroup") + .append(" left join fetch v.tutorGroup as tutorGroup") + .append(" order by v.key"); return dbInstance.getCurrentEntityManager().createQuery(sb.toString(), RepositoryEntryUpgrade.class) .setFirstResult(firstResult) .setMaxResults(maxResults) .getResultList(); } - public RepositoryEntryUpgrade lookupRepositoryEntry(OLATResource ores) { + private RepositoryEntryUpgrade lookupRepositoryEntry(OLATResource ores) { StringBuilder sb = new StringBuilder(); sb.append("select v from ").append(RepositoryEntryUpgrade.class.getName()).append(" v ") .append(" inner join fetch v.olatResource as ores") - .append(" left join fetch v.lifecycle as lifecycle") .append(" left join fetch v.ownerGroup as ownerGroup") .append(" left join fetch v.participantGroup as participantGroup") .append(" left join fetch v.tutorGroup as tutorGroup") diff --git a/src/main/java/org/olat/upgrade/OLATUpgrade_8_4_5.java b/src/main/java/org/olat/upgrade/OLATUpgrade_8_4_5.java index 765d85e50c455d773523e6e14056c14ae6c8c047..2a9f761fddfd0f37c4ac463051c5788ee5d788da 100644 --- a/src/main/java/org/olat/upgrade/OLATUpgrade_8_4_5.java +++ b/src/main/java/org/olat/upgrade/OLATUpgrade_8_4_5.java @@ -19,19 +19,6 @@ */ package org.olat.upgrade; -import java.util.Collections; -import java.util.List; - -import org.olat.basesecurity.BaseSecurity; -import org.olat.core.commons.persistence.DB; -import org.olat.group.BusinessGroup; -import org.olat.group.BusinessGroupOrder; -import org.olat.group.BusinessGroupService; -import org.olat.group.model.SearchBusinessGroupParams; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryManager; -import org.olat.resource.OLATResourceManager; -import org.springframework.beans.factory.annotation.Autowired; /** * Description:<br> @@ -47,20 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired; public class OLATUpgrade_8_4_5 extends OLATUpgrade { private static final String TASK_COURSE_TO_GROUP_PERMISSIONS = "Upgrade course to group permissions"; - private static final int BATCH_SIZE = 20; private static final String VERSION = "OLAT_8.4.5"; - - @Autowired - private DB dbInstance; - @Autowired - private BaseSecurity securityManager; - @Autowired - private OLATResourceManager resourceManager; - @Autowired - private RepositoryManager repositoryManager; - @Autowired - private BusinessGroupService businessGroupService; - public OLATUpgrade_8_4_5() { super(); @@ -102,46 +76,10 @@ public class OLATUpgrade_8_4_5 extends OLATUpgrade { private boolean upgradeCourseToGroup(UpgradeManager upgradeManager, UpgradeHistoryData uhd) { if (!uhd.getBooleanDataValue(TASK_COURSE_TO_GROUP_PERMISSIONS)) { - SearchBusinessGroupParams params = new SearchBusinessGroupParams(); - - int counter = 0; - List<BusinessGroup> groups; - do { - groups = businessGroupService.findBusinessGroups(params, null, counter, BATCH_SIZE, BusinessGroupOrder.nameAsc); - for(BusinessGroup group:groups) { - processBusinessGroup(group); - } - counter += groups.size(); - log.audit("Business group processed: " + groups.size()); - dbInstance.intermediateCommit(); - } while(groups.size() == BATCH_SIZE); - + //do nothing uhd.setBooleanDataValue(TASK_COURSE_TO_GROUP_PERMISSIONS, true); upgradeManager.setUpgradesHistory(uhd, VERSION); } return true; } - - private void processBusinessGroup(BusinessGroup group) { - List<RepositoryEntry> relations = businessGroupService.findRepositoryEntries(Collections.singletonList(group), 0, -1); - for(RepositoryEntry re:relations) { - //add author permission if needed - //TODO group - /* - Policy accessPolicy = securityManager.findPolicy(re.getOwnerGroup(), Constants.PERMISSION_ACCESS, group.getResource()); - if(accessPolicy == null) { - securityManager.createAndPersistPolicyWithResource(re.getOwnerGroup(), Constants.PERMISSION_ACCESS, group.getResource()); - } - //add coach and participant permission if needed - Policy coachPolicy = securityManager.findPolicy(re.getOwnerGroup(), Constants.PERMISSION_ACCESS, group.getResource()); - if(coachPolicy == null) { - securityManager.createAndPersistPolicyWithResource(group.getOwnerGroup(), Constants.PERMISSION_COACH, re.getOlatResource()); - } - Policy participantPolicy = securityManager.findPolicy(re.getOwnerGroup(), Constants.PERMISSION_ACCESS, group.getResource()); - if(participantPolicy == null) { - securityManager.createAndPersistPolicyWithResource(group.getPartipiciantGroup(), Constants.PERMISSION_PARTI, re.getOlatResource()); - } - */ - } - } } \ No newline at end of file diff --git a/src/main/java/org/olat/upgrade/model/BusinessGroupUpgrade.hbm.xml b/src/main/java/org/olat/upgrade/model/BusinessGroupUpgrade.hbm.xml index a1e7eefc8cf13d26fdddd79f8a907955a694e0ee..32b2b041886bfb473c49f1472f02a37c491dc28d 100644 --- a/src/main/java/org/olat/upgrade/model/BusinessGroupUpgrade.hbm.xml +++ b/src/main/java/org/olat/upgrade/model/BusinessGroupUpgrade.hbm.xml @@ -28,8 +28,7 @@ lastUsage helps the SYSTEMADMIN to find the BusinessGroups which were idle for some time. --> - <property name="lastUsage" column="lastusage" type="timestamp" /> - <property name="type" column="businessgrouptype" unique="false" length="15" not-null="true" index="gp_type_idx"/> + <property name="lastUsage" column="lastusage" type="timestamp" /> <property name="externalId" column="external_id" unique="false" not-null="false" type="string"/> <property name="managedFlagsString" column="managed_flags" unique="false" not-null="false" type="string"/> diff --git a/src/main/java/org/olat/upgrade/model/BusinessGroupUpgrade.java b/src/main/java/org/olat/upgrade/model/BusinessGroupUpgrade.java index 1b1f71b713ac95acde29f2791cfbc13b8bddf863..5cd15c4c03b1ec3553bea1cb2c292e30f48ecd53 100644 --- a/src/main/java/org/olat/upgrade/model/BusinessGroupUpgrade.java +++ b/src/main/java/org/olat/upgrade/model/BusinessGroupUpgrade.java @@ -30,7 +30,6 @@ import java.util.Date; import org.olat.basesecurity.Group; import org.olat.basesecurity.SecurityGroup; import org.olat.core.commons.persistence.PersistentObject; -import org.olat.core.logging.AssertException; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; @@ -55,7 +54,6 @@ public class BusinessGroupUpgrade extends PersistentObject implements BusinessGr private String description; private String name; - private String type; private String externalId; private String managedFlagsString; private Integer minParticipants; @@ -79,8 +77,6 @@ public class BusinessGroupUpgrade extends PersistentObject implements BusinessGr private boolean waitingListVisiblePublic; private boolean downloadMembersLists; - private static final int TYPE_MAXLENGTH = 15; - /** * constructs an unitialised BusinessGroup, use setXXX for setting attributes */ @@ -88,31 +84,6 @@ public class BusinessGroupUpgrade extends PersistentObject implements BusinessGr // used by spring } - /** - * convenience constructor - * - * @param type - * @param groupName - * @param description - * @param ownerGroup - * @param partipiciantGroup - */ - public BusinessGroupUpgrade(String groupName, String description, SecurityGroup ownerGroup, SecurityGroup partipiciantGroup, - SecurityGroup waitingGroup) { - this.setName(groupName); - this.setDescription(description); - this.setOwnerGroup(ownerGroup); - this.setPartipiciantGroup(partipiciantGroup); - this.setWaitingGroup(waitingGroup); - this.setType("LearningGroup"); - // per default no waiting-list - Boolean disabled = new Boolean(false); - this.setWaitingListEnabled(disabled); - this.setAutoCloseRanksEnabled(disabled); - this.setLastUsage(new Date()); - this.setLastModified(new Date()); - } - /** * @param partipiciantGroupP */ @@ -291,21 +262,6 @@ public class BusinessGroupUpgrade extends PersistentObject implements BusinessGr this.lastUsage = lastUsage; } - /** - * @see org.olat.group.BusinessGroup#getType() - */ - public String getType() { - return type;// BusinessGroupImpl.class.getName(); - } - - /** - * @param type2 - */ - private void setType(String type2) { - if (type2 != null && type2.length() > TYPE_MAXLENGTH) throw new AssertException("businessgrouptype in o_bg_business too long."); - this.type = type2; - } - /** * @see org.olat.group.BusinessGroup#getDisplayableType(java.util.Locale) */ @@ -375,7 +331,7 @@ public class BusinessGroupUpgrade extends PersistentObject implements BusinessGr * @see java.lang.Object#toString() */ public String toString() { - return "name=" + name + "::" + "type=" + type + "::" + super.toString(); + return "name=" + name + "::" + super.toString(); } public void setWaitingGroup(SecurityGroup waitingGroup) { diff --git a/src/main/java/org/olat/upgrade/model/EPMapUpgrade.hbm.xml b/src/main/java/org/olat/upgrade/model/EPMapUpgrade.hbm.xml index 1c75c30c1e012a8f74b6cb992e627e76d6f2b650..748d7caa4ddfc22e6ddbe55be863c5e4b82e7d79 100644 --- a/src/main/java/org/olat/upgrade/model/EPMapUpgrade.hbm.xml +++ b/src/main/java/org/olat/upgrade/model/EPMapUpgrade.hbm.xml @@ -3,11 +3,9 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.upgrade.model.EPMapUpgrade" table="o_ep_struct_el"> - <id name="key" column="structure_id" type="long" unsaved-value="null"> <generator class="hilo"/> </id> - <property name="structureType" column="structure_type" type="string" /> <many-to-one name="ownerGroup" column="fk_ownergroup" diff --git a/src/main/java/org/olat/upgrade/model/EPMapUpgrade.java b/src/main/java/org/olat/upgrade/model/EPMapUpgrade.java index 08e54bd9df63c5d9334e138f4cbed64d0d6d775b..903b9384728d36b6567a8a93cd7222772805c9c3 100644 --- a/src/main/java/org/olat/upgrade/model/EPMapUpgrade.java +++ b/src/main/java/org/olat/upgrade/model/EPMapUpgrade.java @@ -19,6 +19,10 @@ */ package org.olat.upgrade.model; +import org.olat.basesecurity.Group; +import org.olat.basesecurity.SecurityGroup; +import org.olat.core.commons.persistence.PersistentObject; + /** * Needed to upgrade the maps * @@ -26,6 +30,43 @@ package org.olat.upgrade.model; * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -public class EPMapUpgrade { +public class EPMapUpgrade extends PersistentObject { + + private static final long serialVersionUID = 9041327840189041360L; + + private Group group; + private SecurityGroup ownerGroup; + + public Group getGroup() { + return group; + } + + public void setGroup(Group group) { + this.group = group; + } + + public SecurityGroup getOwnerGroup() { + return ownerGroup; + } + + public void setOwnerGroup(SecurityGroup ownerGroup) { + this.ownerGroup = ownerGroup; + } + + @Override + public int hashCode() { + return getKey() == null ? -9544 : getKey().hashCode(); + } + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(obj instanceof EPMapUpgrade) { + EPMapUpgrade map = (EPMapUpgrade)obj; + return getKey() != null && getKey().equals(map.getKey()); + } + return false; + } } diff --git a/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgrade.hbm.xml b/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgrade.hbm.xml index 225e1d6bb885f6af4cb4ff9db1de060a6d4f1cea..ea0a510413e589068609077cd48b1a5bf1661223 100644 --- a/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgrade.hbm.xml +++ b/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgrade.hbm.xml @@ -12,7 +12,6 @@ <version name="version" access="field" column="version" type="int"/> <property name="lastModified" column="lastmodified" type="timestamp" /> <property name="creationDate" column="creationdate" type="timestamp" /> - <property name="lastUsage" column="lastusage" type="timestamp" /> <property name="softkey"> <!-- softkey takes globalForeverUniqueID which has a max size of 30 characters --> @@ -58,17 +57,10 @@ outer-join="true" unique="true" cascade="none"/> - - <many-to-one name="lifecycle" - column="fk_lifecycle" - class="org.olat.repository.model.RepositoryEntryLifecycle" - outer-join="true" - fetch="join" - cascade="none"/> <set name="groups"> <key column="fk_entry_id"/> - <one-to-many class="org.olat.repository.model.RepositoryEntryToGroupRelation"/> + <one-to-many class="org.olat.upgrade.model.RepositoryEntryUpgradeToGroupRelation"/> </set> <property name="description" type="string"> @@ -104,14 +96,6 @@ <property name="canReference"> <column name="canreference" unique="false" not-null="true"/> </property> - - <property name="launchCounter"> - <column name="launchcounter" unique="false" not-null="true"/> - </property> - - <property name="downloadCounter"> - <column name="downloadcounter" unique="false" not-null="true"/> - </property> <property name="statusCode" column="statuscode" unique="false" type="int"/> </class> diff --git a/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgrade.java b/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgrade.java index 9ab6027536e9b0d122aba3dcf380de3e8f4f2855..a6bf5d7a7b7deecd931899693450d030a7330bd8 100644 --- a/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgrade.java +++ b/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgrade.java @@ -39,13 +39,13 @@ import org.olat.core.util.Formatter; import org.olat.core.util.resource.OresHelper; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryEntryManagedFlag; -import org.olat.repository.model.RepositoryEntryLifecycle; +import org.olat.repository.RepositoryEntryRef; import org.olat.resource.OLATResource; /** *Represents a repository entry. */ -public class RepositoryEntryUpgrade extends PersistentObject implements ModifiedInfo, OLATResourceable { +public class RepositoryEntryUpgrade extends PersistentObject implements ModifiedInfo, OLATResourceable, RepositoryEntryRef { private static final long serialVersionUID = 5319576295875289054L; // IMPORTANT: Keep relation ACC_OWNERS < ACC_OWNERS_AUTHORS < ACC_USERS < ACC_USERS_GUESTS @@ -85,7 +85,6 @@ public class RepositoryEntryUpgrade extends PersistentObject implements Modified private String externalId; private String externalRef; private String managedFlagsString; - private RepositoryEntryLifecycle lifecycle; private int access; private boolean canCopy; @@ -94,10 +93,6 @@ public class RepositoryEntryUpgrade extends PersistentObject implements Modified private boolean canDownload; private boolean membersOnly;//fxdiff VCRP-1,2: access control of resources private int statusCode; - //private List<MetaDataElement> metaDataElements; - private long launchCounter; - private long downloadCounter; - private Date lastUsage; private int version; private Date lastModified; @@ -357,34 +352,6 @@ public class RepositoryEntryUpgrade extends PersistentObject implements Modified public void setMembersOnly(boolean membersOnly) { this.membersOnly = membersOnly; } - - /** - * @return Download count for this repo entry. - */ - public long getDownloadCounter() { - return downloadCounter; - } - - /** - * @return Launch count for this repo entry. - */ - public long getLaunchCounter() { - return launchCounter; - } - - /** - * @param l - */ - public void setDownloadCounter(long l) { - downloadCounter = l; - } - - /** - * @param l - */ - public void setLaunchCounter(long l) { - launchCounter = l; - } /** * @return Returns the displayname. @@ -430,14 +397,6 @@ public class RepositoryEntryUpgrade extends PersistentObject implements Modified this.managedFlagsString = managedFlagsString; } - public RepositoryEntryLifecycle getLifecycle() { - return lifecycle; - } - - public void setLifecycle(RepositoryEntryLifecycle lifecycle) { - this.lifecycle = lifecycle; - } - /** * @see org.olat.core.id.OLATResourceablegetResourceableTypeName() */ @@ -452,20 +411,6 @@ public class RepositoryEntryUpgrade extends PersistentObject implements Modified return getKey(); } - /** - * @return Returns the lastUsage. - */ - public Date getLastUsage() { - return lastUsage; - } - - /** - * @param lastUsage The lastUsage to set. - */ - public void setLastUsage(Date lastUsage) { - this.lastUsage = lastUsage; - } - public int getVersion() { return version; } diff --git a/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgradeToGroupRelation.java b/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgradeToGroupRelation.java index 8b1dbcfd60a874a85e0e01201e52504aa6882c70..ddb7a27d58f25e5dd3014d4f3bfba16d28af1703 100644 --- a/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgradeToGroupRelation.java +++ b/src/main/java/org/olat/upgrade/model/RepositoryEntryUpgradeToGroupRelation.java @@ -36,7 +36,6 @@ import org.hibernate.annotations.GenericGenerator; import org.olat.basesecurity.Group; import org.olat.basesecurity.model.GroupImpl; import org.olat.core.id.Persistable; -import org.olat.repository.RepositoryEntry; /** * @@ -67,7 +66,7 @@ public class RepositoryEntryUpgradeToGroupRelation implements Persistable { @JoinColumn(name="fk_group_id", nullable=false, insertable=true, updatable=false) private Group group; - @ManyToOne(targetEntity=RepositoryEntry.class,fetch=FetchType.LAZY,optional=false) + @ManyToOne(targetEntity=RepositoryEntryUpgrade.class,fetch=FetchType.LAZY,optional=false) @JoinColumn(name="fk_entry_id", nullable=false, insertable=true, updatable=false) private RepositoryEntryUpgrade entry;