Examples of Memento


Examples of org.olat.core.util.memento.Memento

       * mementos are only created in restricted mode
       */
      if (isRestrictedEdit()) {
        String key = nce.getSectionIdent() + "/" + nce.getItemIdent() + "/" + nce.getQuestionIdent() + "/" + nce.getResponseIdent();
        if (!history.containsKey(key)) {
          Memento memento = activeQtiNode.createMemento();
          history.put(key, memento);
          qtiPackage.serializeChangelog(history);
        }
      }

View Full Code Here

Examples of org.olat.core.util.memento.Memento

          if (node instanceof AssessmentNode) {
            AssessmentNode an = (AssessmentNode) node;
            String key = "null/null/null/null";
            if (history.containsKey(key)) {
              // some assessment top level data changed
              Memento mem = (Memento) history.get(key);
              result.append("---+ Changes in test " + formatVariable(startedWithTitle) + ":");
              result.append(an.createChangeMessage(mem));
            }
          } else if (node instanceof SectionNode) {
            SectionNode sn = (SectionNode) node;
            String tmpKey = ((Section) sn.getUnderlyingQTIObject()).getIdent();
            String key = tmpKey + "/null/null/null";
            if (history.containsKey(key)) {
              // some section only data changed
              Memento mem = (Memento) history.get(key);
              result.append("\n---++ Section " + formatVariable(sn.getAltText()) + " changes:");
              result.append(sn.createChangeMessage(mem));
            }
          } else if (node instanceof ItemNode) {
            ItemNode in = (ItemNode) node;
            SectionNode sn = (SectionNode) in.getParent();
            String parentSectkey = ((Section) ((SectionNode) in.getParent()).getUnderlyingQTIObject()).getIdent();
            Item item = (Item) in.getUnderlyingQTIObject();
            Question question = item.getQuestion();
            String itemKey = item.getIdent();
            String prefixKey = "null/" + itemKey;
            String questionIdent = question != null ? question.getQuestion().getId() : "null";
            String key = prefixKey + "/" + questionIdent + "/null";
            StringBuilder changeMessage = new StringBuilder();
            boolean hasChanges = false;

            if (!itemMap.containsKey(itemKey)) {
              Memento questMem = null;
              Memento respMem = null;
              if (history.containsKey(key)) {
                // question changed!
                questMem = (Memento) history.get(key);
                hasChanges = true;
              }
              // if(!hasChanges){
              // check if a response changed
              // new prefix for responses
              prefixKey += "/null/";
              // list contains org.olat.ims.qti.editor.beecom.objects.Response
              List responses = question != null ? question.getResponses() : null;
              if (responses != null && responses.size() > 0) {
                // check for changes in each response
                for (Iterator iter = responses.iterator(); iter.hasNext();) {
                  Response resp = (Response) iter.next();
                  if (history.containsKey(prefixKey + resp.getIdent())) {
                    // this response changed!
                    Memento tmpMem = (Memento) history.get(prefixKey + resp.getIdent());
                    if (respMem != null) {
                      respMem = respMem.getTimestamp() > tmpMem.getTimestamp() ? tmpMem : respMem;
                    } else {
                      hasChanges = true;
                      respMem = tmpMem;
                    }
                  }
                }
              }
              // }
              // output message
              if (hasChanges) {
                Memento mem = null;
                if (questMem != null && respMem != null) {
                  // use the earlier memento
                  mem = questMem.getTimestamp() > respMem.getTimestamp() ? respMem : questMem;
                } else if (questMem != null) {
                  mem = questMem;
View Full Code Here

Examples of org.springframework.richclient.settings.support.Memento

    @Override
    protected void doExecuteCommand() {
        JFileChooser jfc = new JFileChooser();
        jfc.setFileFilter(new XSAnalyzerDefaultFileFilter());

        Memento memento = new JFileChooserMemento(jfc);
        memento.restoreState(settings);

        int result = jfc.showOpenDialog(getParentWindowControl());
        if (JFileChooser.APPROVE_OPTION == result) {
            memento.saveState(settings);
            XsAnalyzerApplicationModel appmodel = (XsAnalyzerApplicationModel) Application.instance().getApplicationContext().getBean("applicationModel");
            appmodel.setSchemaFile(jfc.getSelectedFile());
            appmodel.setSchemaModel(XsModelFactory.createXsModel(appmodel.getSchemaFile()));
            Application.instance().getApplicationContext().publishEvent(new XsAnalyzerApplicationEvent(EventType.OPEN, this));
        }
View Full Code Here

Examples of org.thechiselgroup.choosel.core.client.persistence.Memento

        }
    }

    @Override
    public Memento save(ResourceSetCollector resourceSetCollector) {
        Memento memento = new Memento();

        saveGrouping(memento);
        save(selectionModel, memento, MEMENTO_SELECTION_MODEL,
                resourceSetCollector);
        save(resourceModel, memento, MEMENTO_RESOURCE_MODEL,
                resourceSetCollector);
        memento.addChild(MEMENTO_CONTENT_DISPLAY,
                contentDisplay.save(resourceSetCollector));
        save(model.getSlotMappingConfiguration(), memento,
                MEMENTO_SLOT_MAPPINGS, resourceSetCollector);

        return memento;
View Full Code Here

Examples of org.thechiselgroup.choosel.core.client.persistence.Memento

        return memento;
    }

    // TODO extract constants
    private void saveGrouping(Memento memento) {
        Memento groupingMemento = new Memento();

        ResourceMultiCategorizer categorizer = model.getResourceGrouping()
                .getCategorizer();
        if (categorizer instanceof ResourceByPropertyMultiCategorizer) {
            groupingMemento.setValue("type", "byProperty");
            groupingMemento.setValue("property",
                    ((ResourceByPropertyMultiCategorizer) categorizer)
                            .getProperty());
        } else if (categorizer instanceof ResourceByUriMultiCategorizer) {
            groupingMemento.setValue("type", "byUri");
        }

        memento.addChild(MEMENTO_GROUPING, groupingMemento);
    }
View Full Code Here

Examples of org.thechiselgroup.choosel.core.client.persistence.Memento

        return resourceSet;
    }

    @Override
    public Memento save(ResourceSetCollector resourceSetCollector) {
        Memento memento = new Memento();

        memento.setValue(MEMENTO_SELECTION_SET_COUNT, selectionSets.size());

        for (int i = 0; i < selectionSets.size(); i++) {
            storeResourceSet(resourceSetCollector, memento,
                    MEMENTO_SELECTION_SET_PREFIX + i, selectionSets.get(i));
        }
View Full Code Here

Examples of org.thechiselgroup.choosel.core.client.persistence.Memento

    }

    private void restoreFilter(Memento state,
            PersistableRestorationService restorationService,
            ResourceSetAccessor accessor) {
        Memento child = state.getChild(MEMENTO_FILTER_PREDICATE);
        if (child != null) {
            Predicate<Resource> filterPredicate = (Predicate<Resource>) restorationService
                    .restoreFromMemento(child, accessor);
            filteredResources.setFilterPredicate(filterPredicate);
        }
View Full Code Here

Examples of org.thechiselgroup.choosel.core.client.persistence.Memento

        }
    }

    @Override
    public Memento save(ResourceSetCollector resourceSetCollector) {
        Memento memento = new Memento();

        storeFilterPredicate(resourceSetCollector, memento);
        storeAutomaticResources(resourceSetCollector, memento);
        storeUserResourceSets(resourceSetCollector, memento);
View Full Code Here

Examples of org.thechiselgroup.choosel.core.client.persistence.Memento

            ResourceSetCollector resourceSetCollector, Memento memento) {

        Predicate<Resource> filterPredicate = filteredResources
                .getFilterPredicate();
        if (filterPredicate instanceof Persistable) {
            Memento save = ((Persistable) filterPredicate)
                    .save(resourceSetCollector);
            memento.addChild(MEMENTO_FILTER_PREDICATE, save);
        }
    }
View Full Code Here

Examples of org.thechiselgroup.choosel.core.client.persistence.Memento

            ResourceSetAccessor accessor) {
    }

    @Override
    public Memento save(ResourceSetCollector resourceSetCollector) {
        return new Memento();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.