Package org.thechiselgroup.choosel.core.client.persistence

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


        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

        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

    }

    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

        }
    }

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

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

            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

            ResourceSetAccessor accessor) {
    }

    @Override
    public Memento save(ResourceSetCollector resourceSetCollector) {
        return new Memento();
    }
View Full Code Here

                        ResourceSetCollector collector = (ResourceSetCollector) invocation
                                .getArguments()[0];

                        id.append(collector.storeResourceSet(unmodifiableSet));

                        return new Memento();
                    }
                });

        when(resourceManager.getByUri(createResource(1).getUri())).thenReturn(
                createResource(1));
View Full Code Here

            PersistableRestorationService restorationService,
            ResourceSetAccessor accessor) {

        for (Entry<String, Memento> entry : memento.getChildren().entrySet()) {
            String slotId = entry.getKey();
            Memento child = entry.getValue();

            assert slotsByID.containsKey(slotId) : "no slot with slot id "
                    + slotId;

            Slot slot = slotsByID.get(slotId);

            if (child.getFactoryId() == null) {
                String value = (String) child.getValue(MEMENTO_KEY_TYPE);
                if (MEMENTO_VALUE_FIRST_RESOURCE_PROPERTY.equals(value)) {
                    String property = (String) child
                            .getValue(MEMENTO_KEY_PROPERTY);

                    // TODO assuming that the data in the slot is the correct
                    // kind of data, should definately ask Lars if this is going
                    // ot be ok though
                    setResolver(slot, new FirstResourcePropertyResolver(
                            property, slot.getDataType()));
                } else if (MEMENTO_VALUE_CALCULATION.equals(value)) {
                    String property = (String) child
                            .getValue(MEMENTO_KEY_PROPERTY);
                    String calculationType = (String) child
                            .getValue(MEMENTO_KEY_CALCULATION_TYPE);

                    if ("min".equals(calculationType)) {
                        setResolver(slot, new CalculationResolver(property,
                                Subset.ALL, new MinCalculation()));
View Full Code Here

        }
    }

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

        for (Entry<Slot, ViewItemValueResolver> entry : slotsToValueResolvers
                .entrySet()) {

            Slot slot = entry.getKey();
            ViewItemValueResolver resolver = entry.getValue();

            Memento child = new Memento();

            if (resolver instanceof FirstResourcePropertyResolver) {
                child.setValue(MEMENTO_KEY_TYPE,
                        MEMENTO_VALUE_FIRST_RESOURCE_PROPERTY);
                child.setValue(MEMENTO_KEY_PROPERTY,
                        ((FirstResourcePropertyResolver) resolver)
                                .getProperty());
            } else if (resolver instanceof CalculationResolver) {
                child.setValue(MEMENTO_KEY_TYPE, MEMENTO_VALUE_CALCULATION);

                Calculation calculation = ((CalculationResolver) resolver)
                        .getCalculation();
                child.setValue(MEMENTO_KEY_PROPERTY,
                        ((CalculationResolver) resolver).getProperty());

                if (calculation instanceof SumCalculation) {
                    child.setValue(MEMENTO_KEY_CALCULATION_TYPE, "sum");
                } else if (calculation instanceof AverageCalculation) {
                    child.setValue(MEMENTO_KEY_CALCULATION_TYPE, "average");
                } else if (calculation instanceof MinCalculation) {
                    child.setValue(MEMENTO_KEY_CALCULATION_TYPE, "min");
                } else if (calculation instanceof MaxCalculation) {
                    child.setValue(MEMENTO_KEY_CALCULATION_TYPE, "max");
                }
            } else if (resolver instanceof Persistable) {
                child = ((Persistable) resolver).save(resourceSetCollector);
            }
View Full Code Here

TOP

Related Classes of org.thechiselgroup.choosel.core.client.persistence.Memento

Copyright © 2018 www.massapicom. 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.