Exemple #1
0
 @SuppressWarnings("unused")
 @Override
 protected void event(final UserRequest ureq, final Component source, final Event event) {
   if (source instanceof Link) {
     final Link link = (Link) source;
     if (link.getCommand().equals(DELETE_LINK_CMD)) {
       if (artefactNodeClicked != null) {
         final AbstractArtefact artefact =
             ePFMgr.loadArtefactByKey(new Long(getArtefactIdFromNodeId(artefactNodeClicked)));
         final PortfolioStructure parentStruct =
             ePFMgr.loadPortfolioStructureByKey(
                 new Long(getArtefactParentStructIdFromNodeId(artefactNodeClicked)));
         ePFMgr.removeArtefactFromStructure(artefact, parentStruct);
         // refresh the view
         fireEvent(ureq, Event.CHANGED_EVENT);
       } else if (structureClicked != null) {
         if ((structureClicked instanceof EPPage)
             && !(structureClicked instanceof EPAbstractMap)) {
           PortfolioStructure ps = structureClicked;
           while (ePFMgr.loadStructureParent(ps) != null) {
             ps = ePFMgr.loadStructureParent(ps);
           }
           final int childPages = ePFMgr.countStructureChildren(ps);
           if (childPages > 1) {
             eSTMgr.removeStructureRecursively(structureClicked);
             // refresh the view
             fireEvent(ureq, Event.CHANGED_EVENT);
           } else {
             showError("last.page.not.deletable");
           }
         } else if (structureClicked instanceof EPStructureElement
             && !(structureClicked instanceof EPAbstractMap)) {
           // structures should always be deletable
           eSTMgr.removeStructureRecursively(structureClicked);
           // refresh the view
           fireEvent(ureq, Event.CHANGED_EVENT);
         } else {
           showInfo("element.not.deletable");
         }
       }
     }
   }
 }
 @Override
 public void repositoryEntryCreated(final RepositoryEntry re) {
   final PortfolioStructureMap mapTemp =
       eSTMgr.createAndPersistPortfolioMapTemplateFromEntry(getIdentity(), re);
   // add a page, as each map should have at least one per default!
   final Translator pt =
       PackageUtil.createPackageTranslator(
           EPCreateMapController.class, getLocale(), getTranslator());
   final String title = pt.translate("new.page.title");
   final String description = pt.translate("new.page.desc");
   if (isNewTemplateAndGetsAPage) { // no additional page when this is a copy.
     final EPFrontendManager ePFMgr =
         (EPFrontendManager) CoreSpringFactory.getBean(EPFrontendManager.class);
     ePFMgr.createAndPersistPortfolioPage(mapTemp, title, description);
   }
 }
 /**
  * Constructor
  *
  * @param addCallback
  * @param ureq
  * @param wControl
  */
 public CreateStructureMapTemplateController(
     final RepositoryAddCallback addCallback,
     final UserRequest ureq,
     final WindowControl wControl) {
   super(ureq, wControl);
   eSTMgr = (PortfolioStructureDao) CoreSpringFactory.getBean(PortfolioStructureDao.class);
   if (addCallback != null) {
     // create a new template
     isNewTemplateAndGetsAPage = true;
     templateOres = eSTMgr.createPortfolioMapTemplateResource();
     addCallback.setDisplayName(translate(templateOres.getResourceableTypeName()));
     addCallback.setResourceable(templateOres);
     addCallback.setResourceName(translate("EPStructuredMapTemplate"));
     addCallback.finished(ureq);
   }
 }