diff --git a/src/main/java/org/olat/repository/RepositoryService.java b/src/main/java/org/olat/repository/RepositoryService.java index 98ebfdb60f5cb2d9a40c185e4add5b64e426fe10..e471126db142c5f70db6707537bbd58ef6302b26 100644 --- a/src/main/java/org/olat/repository/RepositoryService.java +++ b/src/main/java/org/olat/repository/RepositoryService.java @@ -50,7 +50,7 @@ public interface RepositoryService { public RepositoryEntry create(String initialAuthor, String resourceName, String displayname, String description, OLATResource resource); - public RepositoryEntry copy(RepositoryEntry sourceEntry, Identity author, String displayname, String description); + public RepositoryEntry copy(RepositoryEntry sourceEntry, Identity author, String displayname); public RepositoryEntry loadByKey(Long key); diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties index fd10ac1bcef81ba0c0dcfa37c772f04d7bc6d3c8..ff12a47503561b452ff66fa3b25065535dfd33f5 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties @@ -254,6 +254,7 @@ cmd.import.ressource.desc=W\u00E4hlen Sie eine Lernressource f\u00FCr den Import comments=Kommentar confirmation.no.toolHelp=Aktion abbrechen. confirmation.yes.toolHelp=Lernressource l\u00F6schen. +copy.suffix= (Kopie) course.config.changed.text=Sie m\u00F6chten die Kurseinstellungen \u00E4ndern. Wenn Sie 'Ja' klicken, m\u00FCssen {0} Personen im Kurs den Kurs neu starten. Bei 'Nein' werden die \u00C4nderungen verworfen. Wollen Sie fortfahren? course.config.changed.title=\u00C4nderung der Einstellungen course.made.by=mit diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties index 0b0f5bce22a4ac7484eb333ba0cc85cadf4f0ceb..a72fcb8330dab31deb09a301fab5850c6a1e895c 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties @@ -253,6 +253,7 @@ cmd.import.ressource.desc=Choose a learning resource to import\:<ul><li>OpenOLAT comments=Comments confirmation.no.toolHelp=Cancel action. confirmation.yes.toolHelp=Delete learning resource. +copy.suffix= (copy) course.config.changed.text=You want to modify your course settings. When clicking on 'Yes' {0} participants will have to restart this course. When clicking on 'No' all modifications will be discarded. Do you wish to proceed? course.config.changed.title=Modification of settings course.made.by=with diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties index 0d5c6d78e91350e9c9690bfe1f41e339535fa7af..3058d5f7af693fb427eb3cde518931d408712b60 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties @@ -255,6 +255,7 @@ cmd.import.ressource.desc=Choisissez une ressource didactique \u00E0 importer\:< comments=Commentaires confirmation.no.toolHelp=Annuler l'op\u00E9ration confirmation.yes.toolHelp=Supprimer la ressource +copy.suffix= (copie) course.config.changed.text=Vous voulez modifier les r\u00E9glages du cours. Si vous cliquez 'oui' les personnes utilisant le cours doivent red\u00E9marrer le cours. Si vous cliquez sur 'non', les modifications ne sont pas retenues. Voulez-vous continuer? course.config.changed.title=Modification des r\u00E9glages course.made.by=avec diff --git a/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java b/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java index 505ee181f9cad92468bc6131ec3e800660fff739..88d441dd948f16865470fc680cc6d0dc4c230ff1 100644 --- a/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java +++ b/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java @@ -186,15 +186,25 @@ public class RepositoryServiceImpl implements RepositoryService { } @Override - public RepositoryEntry copy(RepositoryEntry sourceEntry, Identity author, String displayname, String description) { + public RepositoryEntry copy(RepositoryEntry sourceEntry, Identity author, String displayname) { OLATResource sourceResource = sourceEntry.getOlatResource(); OLATResource copyResource = resourceManager.createOLATResourceInstance(sourceResource.getResourceableTypeName()); RepositoryEntry copyEntry = create(author, null, sourceEntry.getResourcename(), displayname, - description, copyResource, RepositoryEntry.ACC_OWNERS); + sourceEntry.getDescription(), copyResource, RepositoryEntry.ACC_OWNERS); + + //copy all fields + copyEntry.setAuthors(sourceEntry.getAuthors()); + copyEntry.setCredits(sourceEntry.getCredits()); + copyEntry.setExpenditureOfWork(sourceEntry.getExpenditureOfWork()); + copyEntry.setMainLanguage(sourceEntry.getMainLanguage()); + copyEntry.setObjectives(sourceEntry.getObjectives()); + copyEntry.setRequirements(sourceEntry.getRequirements()); + copyEntry = dbInstance.getCurrentEntityManager().merge(copyEntry); RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(sourceEntry); copyEntry = handler.copy(sourceEntry, copyEntry); + //copy the image RepositoryManager.getInstance().copyImage(sourceEntry, copyEntry); diff --git a/src/main/java/org/olat/repository/ui/author/AuthorListController.java b/src/main/java/org/olat/repository/ui/author/AuthorListController.java index b355104563b25688ea37b55a517157893cba30c0..a63855702d3e7fd2d507d24c9b890c03e9b85c57 100644 --- a/src/main/java/org/olat/repository/ui/author/AuthorListController.java +++ b/src/main/java/org/olat/repository/ui/author/AuthorListController.java @@ -721,8 +721,7 @@ public class AuthorListController extends FormBasicController implements Activat for(AuthoringEntryRow row:rows) { RepositoryEntry sourceEntry = repositoryService.loadByKey(row.getKey()); String displayname = "Copy of " + sourceEntry.getDisplayname(); - String description = sourceEntry.getDescription(); - repositoryService.copy(sourceEntry, getIdentity(), displayname, description); + repositoryService.copy(sourceEntry, getIdentity(), displayname); } showInfo("details.copy.success", new String[]{ Integer.toString(rows.size()) }); diff --git a/src/main/java/org/olat/repository/ui/author/CopyRepositoryEntryController.java b/src/main/java/org/olat/repository/ui/author/CopyRepositoryEntryController.java index 0f20a00b5d1ff3b6a0a2130fd77987d7414452b5..10de6d58e0d99cbfeeaa1a04a9b594e475dcadef 100644 --- a/src/main/java/org/olat/repository/ui/author/CopyRepositoryEntryController.java +++ b/src/main/java/org/olat/repository/ui/author/CopyRepositoryEntryController.java @@ -21,26 +21,18 @@ package org.olat.repository.ui.author; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.form.flexible.FormItemContainer; -import org.olat.core.gui.components.form.flexible.elements.RichTextElement; import org.olat.core.gui.components.form.flexible.elements.TextElement; import org.olat.core.gui.components.form.flexible.impl.FormBasicController; import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; -import org.olat.core.logging.activity.LearningResourceLoggingAction; -import org.olat.core.logging.activity.OlatResourceableType; -import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.StringHelper; import org.olat.core.util.Util; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; import org.olat.repository.RepositoryService; -import org.olat.repository.handlers.RepositoryHandler; -import org.olat.repository.handlers.RepositoryHandlerFactory; -import org.olat.resource.OLATResource; import org.olat.resource.OLATResourceManager; -import org.olat.util.logging.activity.LoggingResourceable; import org.springframework.beans.factory.annotation.Autowired; /** @@ -52,7 +44,6 @@ import org.springframework.beans.factory.annotation.Autowired; public class CopyRepositoryEntryController extends FormBasicController { private TextElement displaynameEl; - private RichTextElement descriptionEl; private RepositoryEntry copyEntry; private final RepositoryEntry sourceEntry; @@ -75,13 +66,10 @@ public class CopyRepositoryEntryController extends FormBasicController { @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { String sourceName = StringHelper.escapeHtml(sourceEntry.getDisplayname()); + sourceName += " " + translate("copy.suffix"); displaynameEl = uifactory.addTextElement("cif.displayname", "cif.displayname", 100, sourceName, formLayout); displaynameEl.setDisplaySize(30); displaynameEl.setMandatory(true); - - descriptionEl = uifactory.addRichTextElementForStringData("cif.description", "cif.description", - "", 10, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl()); - descriptionEl.getEditorConfiguration().setFileBrowserUploadRelPath("media"); FormLayoutContainer buttonContainer = FormLayoutContainer.createButtonLayout("buttonContainer", getTranslator()); formLayout.add("buttonContainer", buttonContainer); @@ -101,13 +89,13 @@ public class CopyRepositoryEntryController extends FormBasicController { @Override protected void formOK(UserRequest ureq) { - doCopy(); + String displayname = displaynameEl.getValue(); + copyEntry = repositoryService.copy(sourceEntry, getIdentity(), displayname); fireEvent(ureq, Event.DONE_EVENT); } @Override protected void formCancelled(UserRequest ureq) { - doCleanUp(); fireEvent(ureq, Event.CANCELLED_EVENT); } @@ -126,30 +114,4 @@ public class CopyRepositoryEntryController extends FormBasicController { return allOk & super.validateFormLogic(ureq); } - - private void doCopy() { - String displayname = displaynameEl.getValue(); - String description = descriptionEl.getValue(); - - OLATResource sourceResource = sourceEntry.getOlatResource(); - OLATResource copyResource = resourceManager.createOLATResourceInstance(sourceResource.getResourceableTypeName()); - copyEntry = repositoryService.create(getIdentity(), null, sourceEntry.getResourcename(), displayname, - description, copyResource, RepositoryEntry.ACC_OWNERS); - - RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(sourceEntry); - copyEntry = handler.copy(sourceEntry, copyEntry); - - //copy the image - RepositoryManager.getInstance().copyImage(sourceEntry, copyEntry); - - ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_CREATE, getClass(), - LoggingResourceable.wrap(copyEntry, OlatResourceableType.genRepoEntry)); - - repositoryManager.triggerIndexer(copyEntry); - } - - - private void doCleanUp() { - //remove repo - } } \ No newline at end of file