Package org.thechiselgroup.choosel.workbench.client.workspace.dto

Examples of org.thechiselgroup.choosel.workbench.client.workspace.dto.ViewDTO


            pm.close();
        }
    }

    private ViewDTO toViewDTO(PersistentView pView) {
        ViewDTO dto = new ViewDTO();

        dto.setId(pView.getId());
        dto.setTitle(pView.getTitle());
        dto.setResources(pView.getResources());
        dto.setResourceSets(pView.getResourceSets());
        dto.setContentType(pView.getContentType());
        dto.setTitle(pView.getTitle());
        dto.setViewState(pView.getViewState());

        return dto;
    }
View Full Code Here


    }

    private ViewDTO createViewDTO(View view) {
        assert view instanceof Persistable;

        ViewDTO viewDTO = new ViewDTO();

        DefaultResourceSetCollector persistanceManager = new DefaultResourceSetCollector();

        // TODO use view content label instead of window title
        // viewDTO.setTitle(window.getWindowTitle()); We will eventually store
        // the title

        viewDTO.setContentType(view.getContentType());

        Persistable persistable = view;
        viewDTO.setViewState(persistable.save(persistanceManager));

        // Resource set DTOs
        // 1. resolved unmodified sets --> changes list size
        List<ResourceSet> resourceSets = new ArrayList<ResourceSet>(
                persistanceManager.getResourceSets());
        for (ResourceSet resourceSet : resourceSets) {
            if (resourceSet instanceof UnmodifiableResourceSet) {
                persistanceManager
                        .storeResourceSet(((UnmodifiableResourceSet) resourceSet)
                                .getDelegate());
            }
        }

        // 2. store sets
        ResourceSet resourceCollector = new DefaultResourceSet();
        ResourceSetDTO[] resourceSetDTOs = new ResourceSetDTO[persistanceManager
                .getResourceSets().size()];
        for (int i = 0; i < persistanceManager.getResourceSets().size(); i++) {
            ResourceSetDTO dto = new ResourceSetDTO();
            ResourceSet resourceSet = persistanceManager.getResourceSets().get(
                    i);

            if (resourceSet.hasLabel()) {
                dto.setLabel(resourceSet.getLabel());
            }

            dto.setId(i);

            if (resourceSet instanceof UnmodifiableResourceSet) {
                ResourceSet sourceSet = ((UnmodifiableResourceSet) resourceSet)
                        .getDelegate();

                dto.setDelegateSetId(persistanceManager
                        .storeResourceSet(sourceSet));
            } else {
                List<String> resourceIds = new ArrayList<String>();
                for (Resource resource : resourceSet) {
                    resourceCollector.add(resource);
                    resourceIds.add(resource.getUri());
                }
                dto.setResourceIds(resourceIds);
            }

            resourceSetDTOs[i] = dto;
        }
        viewDTO.setResourceSets(resourceSetDTOs);

        Resource[] resources = new Resource[resourceCollector.size()];
        int count = 0;
        for (Resource resource : resourceCollector) {
            resources[count++] = resource;
        }

        viewDTO.setResources(resources);

        viewDTO.setTitle(view.getLabel());

        return viewDTO;
    }
View Full Code Here

    @Override
    public void saveView(final DefaultShareConfiguration shareConfiguration,
            final AsyncCallback<Long> callback) {
        assert callback != null;

        ViewDTO viewDTO = createViewDTO(shareConfiguration.getView());

        service.saveView(viewDTO, new AsyncCallbackDelegate<Long>(callback) {
            @Override
            public void onFailure(Throwable caught) {
                loggingErrorHandler.handleError(caught);
View Full Code Here

TOP

Related Classes of org.thechiselgroup.choosel.workbench.client.workspace.dto.ViewDTO

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.