Search in sources :

Example 1 with GlossaryResource

use of org.olat.fileresource.types.GlossaryResource in project openolat by klemens.

the class GlossaryManagerImpl method createGlossary.

/**
 * Creates a glossary resource and creates the necessary folders on disk. The
 * glossary will be placed in the resources _unizipped dir to make import /
 * export easier
 *
 * @return
 */
@Override
public GlossaryResource createGlossary() {
    GlossaryResource resource = new GlossaryResource();
    VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
    if (rootContainer == null)
        return null;
    if (rootContainer.createChildContainer(INTERNAL_FOLDER_NAME) == null)
        return null;
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.createOLATResourceInstance(resource);
    rm.saveOLATResource(ores);
    return resource;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) GlossaryResource(org.olat.fileresource.types.GlossaryResource)

Example 2 with GlossaryResource

use of org.olat.fileresource.types.GlossaryResource in project OpenOLAT by OpenOLAT.

the class CourseHandler method importGlossary.

private void importGlossary(ICourse course, Identity owner) {
    GlossaryManager gm = GlossaryManager.getInstance();
    RepositoryEntryImportExport importExport = gm.getRepositoryImportExport(course.getCourseExportDataDir().getBasefile());
    GlossaryResource resource = gm.createGlossary();
    if (resource == null) {
        log.error("Error adding glossary directry during repository reference import: " + importExport.getDisplayName());
        return;
    }
    // unzip contents
    VFSContainer glossaryContainer = gm.getGlossaryRootFolder(resource);
    File fExportedFile = importExport.importGetExportedFile();
    if (fExportedFile.exists()) {
        ZipUtil.unzip(new LocalFileImpl(fExportedFile), glossaryContainer);
    } else {
        log.warn("The actual contents of the glossary were not found in the export.");
    }
    // create repository entry
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    OLATResource ores = OLATResourceManager.getInstance().findOrPersistResourceable(resource);
    RepositoryEntry importedRepositoryEntry = repositoryService.create(owner, null, importExport.getResourceName(), importExport.getDisplayName(), importExport.getDescription(), ores, 0);
    // set the new glossary reference
    CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
    courseConfig.setGlossarySoftKey(importedRepositoryEntry.getSoftkey());
    CoreSpringFactory.getImpl(ReferenceManager.class).addReference(course, importedRepositoryEntry.getOlatResource(), GlossaryManager.GLOSSARY_REPO_REF_IDENTIFYER);
    CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) GlossaryManager(org.olat.modules.glossary.GlossaryManager) File(java.io.File) GlossaryResource(org.olat.fileresource.types.GlossaryResource) RepositoryService(org.olat.repository.RepositoryService) CourseConfig(org.olat.course.config.CourseConfig) ReferenceManager(org.olat.resource.references.ReferenceManager)

Example 3 with GlossaryResource

use of org.olat.fileresource.types.GlossaryResource in project OpenOLAT by OpenOLAT.

the class GlossaryHandler method createResource.

@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    GlossaryResource glossaryResource = GlossaryManager.getInstance().createGlossary();
    OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(glossaryResource);
    RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    DBFactory.getInstance().commit();
    return re;
}
Also used : OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryService(org.olat.repository.RepositoryService) GlossaryResource(org.olat.fileresource.types.GlossaryResource)

Example 4 with GlossaryResource

use of org.olat.fileresource.types.GlossaryResource in project OpenOLAT by OpenOLAT.

the class GlossaryHandler method importResource.

@Override
public RepositoryEntry importResource(Identity initialAuthor, String initialAuthorAlt, String displayname, String description, boolean withReferences, Locale locale, File file, String filename) {
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    GlossaryResource glossaryResource = GlossaryManager.getInstance().createGlossary();
    OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(glossaryResource);
    // copy resources
    File glossyPath = GlossaryManager.getInstance().getGlossaryRootFolder(glossaryResource).getBasefile();
    FileResource.copyResource(file, filename, glossyPath);
    RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    DBFactory.getInstance().commit();
    return re;
}
Also used : OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) RepositoryService(org.olat.repository.RepositoryService) GlossaryResource(org.olat.fileresource.types.GlossaryResource)

Example 5 with GlossaryResource

use of org.olat.fileresource.types.GlossaryResource in project OpenOLAT by OpenOLAT.

the class GlossaryManagerImpl method createGlossary.

/**
 * Creates a glossary resource and creates the necessary folders on disk. The
 * glossary will be placed in the resources _unizipped dir to make import /
 * export easier
 *
 * @return
 */
@Override
public GlossaryResource createGlossary() {
    GlossaryResource resource = new GlossaryResource();
    VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
    if (rootContainer == null)
        return null;
    if (rootContainer.createChildContainer(INTERNAL_FOLDER_NAME) == null)
        return null;
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.createOLATResourceInstance(resource);
    rm.saveOLATResource(ores);
    return resource;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) GlossaryResource(org.olat.fileresource.types.GlossaryResource)

Aggregations

GlossaryResource (org.olat.fileresource.types.GlossaryResource)8 OLATResource (org.olat.resource.OLATResource)8 RepositoryEntry (org.olat.repository.RepositoryEntry)6 RepositoryService (org.olat.repository.RepositoryService)6 File (java.io.File)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 CourseConfig (org.olat.course.config.CourseConfig)2 GlossaryManager (org.olat.modules.glossary.GlossaryManager)2 RepositoryEntryImportExport (org.olat.repository.RepositoryEntryImportExport)2 OLATResourceManager (org.olat.resource.OLATResourceManager)2 ReferenceManager (org.olat.resource.references.ReferenceManager)2