Package net.sf.archimede.model.collection

Examples of net.sf.archimede.model.collection.Collection


        DatabaseUtil dbUtil = DatabaseUtil.getSingleton();
        try {
            //FIXME Do not hardcode
            dbUtil.beginTransaction(new CredentialsWrapper(username, password));
           
            Collection folderCollection = this.createOrGetThesisCollection(thesisMetadata);
            if (folderCollection.getFolders() == null) {
                folderCollection.setFolders( new ArrayList() );
            }
            folderCollection.getFolders().add(thesisFolder);
            thesisFolder.setParentCollection(folderCollection);
            if (thesisFolder.getReadUsers() == null) {
                thesisFolder.setReadUsers(new ArrayList());
            }
            thesisFolder.getReadUsers().add(new UserImpl("anonymous", ""));
View Full Code Here


        thesisFolder.setStoredFiles(storedFiles);
    }
   
    private Collection createOrGetThesisCollection(ThesisMetadata thesisMetadata) throws ObjectLockedException, ObjectExistsException {
        CollectionDao collectionDao = CollectionDao.createInstance();
        Collection rootCollection = collectionDao.getRootCollection();
       
        Collection thesisCollection = this.createOrGetCollection(rootCollection, this.thesesCollectionName);
       
        String classification = thesisMetadata.getClassification();
        Collection classificationCollection = this.createOrGetCollection(thesisCollection, classification);
       
        String level = thesisMetadata.getLevel();
        Collection levelCollection = this.createOrGetCollection(classificationCollection, level);
       
        String year = thesisMetadata.getYear();
        return this.createOrGetCollection(levelCollection, year);
    }
View Full Code Here

    }
   
    private Collection createOrGetCollection(Collection parentCollection, String newCollectionName) throws ObjectLockedException, ObjectExistsException {
        List collections = parentCollection.getCollections();
        boolean found = false;
        Collection collection = null;
        if (collections != null) {
            for (Iterator it = collections.iterator(); it.hasNext(); ) {
                Collection currentCollection = (Collection) it.next();
                if (currentCollection.getName().equals(newCollectionName)) {
                    found = true;
                    collection = currentCollection;
                    break;
                }
            }
        }
        if (!found) {
            if (parentCollection.getCollections() == null) {
                parentCollection.setCollections(new ArrayList());
            }
            Collection newCollection = new CollectionImpl();
            newCollection.setName(newCollectionName);
            newCollection.setParent(parentCollection);
            parentCollection.getCollections().add(newCollection);
            collection = newCollection;
           
            if (newCollection.getReadUsers() == null) {
                newCollection.setReadUsers(new ArrayList());
            }
            newCollection.getReadUsers().add(new UserImpl("anonymous", ""));
           
            CollectionDao.createInstance().save(newCollection);
        }
       
        return collection;
View Full Code Here

    public boolean existsInRepository() throws TransactionException {
      
        if (this.exists == null) {
            this.exists = Boolean.valueOf(false);
           
            Collection groupCollection = getGroupInRepository();
            if (groupCollection != null) {
                Collection seriesCollection = getSeriesInRepository(groupCollection);
                if (seriesCollection != null) {
                    Folder folder = getFolderInRepository(seriesCollection);
                    this.exists = Boolean.valueOf(folder != null);
                }
            }           
View Full Code Here

        return this.exists.booleanValue();
    }
   
    private Collection getGroupInRepository() throws TransactionException {
        CollectionDao collectionDao = CollectionDao.createInstance();
        Collection rootCollection = collectionDao.getRootCollection();
       
        List collections = rootCollection.getCollections();
        //Community
        for (Iterator collIt = collections.iterator(); collIt.hasNext(); ){
            Collection currentCollection = (Collection) collIt.next();
            Collection comparisonCollection = new CollectionImpl();
            comparisonCollection.setName(this.oldFolder.getGroupName());
            if (currentCollection.getName().equals(comparisonCollection.getName())) {
               return currentCollection;
            }
        }
       
        return null;
View Full Code Here

        if (collections == null) {
            return null;
        }
        //Community
        for (Iterator collIt = collections.iterator(); collIt.hasNext(); ) {
            Collection currentCollection = (Collection) collIt.next();
            Collection comparisonCollection = new CollectionImpl();
            comparisonCollection.setName(this.oldFolder.getSeriesName());
            if (currentCollection.getName().equals(comparisonCollection.getName())) {
               return currentCollection;
            }
        }
       
        return null;
View Full Code Here

       
        if (this.exists != null && this.exists.equals(Boolean.valueOf(true))) {
            throw new IllegalStateException("Cannot insert folder: Folder already exists.");
        }
       
        Collection groupCollection = getGroupInRepository();
        if (groupCollection == null) {
            CollectionDao collectionDao = CollectionDao.createInstance();
            Collection rootCollection = collectionDao.getRootCollection();
            groupCollection = new CollectionImpl();
            groupCollection.setName(this.oldFolder.getGroupName());
            groupCollection.setParent(rootCollection);
           
            if (groupCollection.getReadUsers() == null) {
              groupCollection.setReadUsers(new ArrayList());
            }
            groupCollection.getReadUsers().add(new UserImpl("anonymous", ""));
           
            if (rootCollection.getCollections() != null) {
                rootCollection.getCollections().add(groupCollection);
            } else {
                List collections = new ArrayList();
                collections.add(groupCollection);
                rootCollection.setCollections(collections);
            }
           
            collectionDao.save(groupCollection);
        }
           
        Collection seriesCollection = getSeriesInRepository(groupCollection);
        if (seriesCollection == null) {
            CollectionDao collectionDao = CollectionDao.createInstance();
            seriesCollection = new CollectionImpl();
            seriesCollection.setName(this.oldFolder.getSeriesName());
            seriesCollection.setParent(groupCollection);
           
            if (seriesCollection.getReadUsers() == null) {
              seriesCollection.setReadUsers(new ArrayList());
            }
            seriesCollection.getReadUsers().add(new UserImpl("anonymous", ""));
           
            if (groupCollection.getCollections() != null) {
                groupCollection.getCollections().add(seriesCollection);
            } else {
                List collections = new ArrayList();
                collections.add(seriesCollection);
                groupCollection.setCollections(collections);
            }
            collectionDao.save(seriesCollection);
           
        }
        Folder folder = getFolderInRepository(seriesCollection);
        if (folder == null) {
            folder = new FolderImpl();
            folder.setName(this.oldFolder.getOiDb());
            folder.setDatestamp(new GregorianCalendar());
            folder.setParentCollection(seriesCollection);
           
            if (folder.getReadUsers() == null) {
              folder.setReadUsers(new ArrayList());
            }
            folder.getReadUsers().add(new UserImpl("anonymous", ""));
           
            if (seriesCollection.getFolders() != null) {
                seriesCollection.getFolders().add(folder);
            } else {
                List folders = new ArrayList();
                folders.add(folder);
                seriesCollection.setFolders(folders);
            }
           
           
            FolderDao folderDao = FolderDao.createInstance();
            folderDao.save(folder);
View Full Code Here

            List sets = new ArrayList();
            List collections = listCollections();
            int count = 0;
            //&& count < this.limitPerRequest; count++
            for (Iterator it = collections.iterator(); it.hasNext();) {
                Collection currentCollection = (Collection) it.next();
                sets.add(getSetXML(getSetSpec(currentCollection), getSetName(currentCollection), currentCollection.getDescription()));
            }
            listSetsMap.put("sets", sets.iterator());
            //listSetsMap.put("resumptionMap", getResumptionMap("0", collections.size(), 0));   
            return listSetsMap;
        } finally {
View Full Code Here

            List sets = new ArrayList();
            List collections = listCollections();
            int count = 0;
            for (Iterator it = collections.iterator(); it.hasNext() && count < limitPerRequest;) {
                if (count > cursor + this.limitPerRequest) {
                    Collection currentCollection = (Collection) it.next();
                    sets.add(getSetXML(getSetSpec(currentCollection), getSetName(currentCollection), currentCollection.getDescription()));
                    count++;
                }
            }
            listSetsMap.put("sets", sets.iterator());
            listSetsMap.put("resumptionMap", getResumptionMap("" + cursor, collections.size(), cursor));
View Full Code Here

    public void setFolders(DataModel folders1) {
        this.folders = folders1;       
    }
   
    public String seeParentCollectionFromFolder() {
        Collection collection = (Collection) this.selectedFolder.getParentCollectionsModel().getRowData();  
        CollectionBean collectionBean = (CollectionBean) FacesContext.getCurrentInstance().getApplication().createValueBinding(CollectionBean.BEAN_REF).getValue(FacesContext.getCurrentInstance());
        collectionBean.setSelectedCollection(new ViewCollection(collection));
       
        return "exploration_collection_description";
    }
View Full Code Here

TOP

Related Classes of net.sf.archimede.model.collection.Collection

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.