Search in sources :

Example 1 with LicenseService

use of org.olat.core.commons.services.license.LicenseService in project OpenOLAT by OpenOLAT.

the class QTIMetadataConverter method addLicenseMetadataField.

private void addLicenseMetadataField(String label, QuestionItemFull fullItem, Element metadata) {
    LicenseService lService = CoreSpringFactory.getImpl(LicenseService.class);
    ResourceLicense license = lService.loadLicense(fullItem);
    if (license != null) {
        String licenseText = null;
        LicenseType licenseType = license.getLicenseType();
        if (lService.isFreetext(licenseType)) {
            licenseText = license.getFreetext();
        } else if (!lService.isNoLicense(licenseType)) {
            licenseText = license.getLicenseType().getName();
        }
        if (StringHelper.containsNonWhitespace(licenseText)) {
            addMetadataField(label, licenseText, metadata);
        }
    }
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 2 with LicenseService

use of org.olat.core.commons.services.license.LicenseService in project OpenOLAT by OpenOLAT.

the class ManifestMetadataBuilder method appendMetadataFrom.

/**
 * This method will add new metadata to the current ones.
 *
 * @param item
 * @param locale
 */
public void appendMetadataFrom(QuestionItem item, AssessmentItem assessmentItem, Locale locale) {
    String lang = item.getLanguage();
    if (!StringHelper.containsNonWhitespace(lang)) {
        lang = locale.getLanguage();
    }
    // LOM : General
    if (StringHelper.containsNonWhitespace(item.getTitle())) {
        setTitle(item.getTitle(), lang);
    }
    if (StringHelper.containsNonWhitespace(item.getCoverage())) {
        setCoverage(item.getCoverage(), lang);
    }
    if (StringHelper.containsNonWhitespace(item.getKeywords())) {
        setGeneralKeywords(item.getKeywords(), lang);
    }
    if (StringHelper.containsNonWhitespace(item.getDescription())) {
        setDescription(item.getDescription(), lang);
    }
    // LOM : Technical
    setTechnicalFormat(ManifestBuilder.ASSESSMENTITEM_MIMETYPE);
    // LOM : Educational
    if (StringHelper.containsNonWhitespace(item.getEducationalContextLevel())) {
        setEducationalContext(item.getEducationalContextLevel(), lang);
    }
    if (StringHelper.containsNonWhitespace(item.getEducationalLearningTime())) {
        setEducationalLearningTime(item.getEducationalLearningTime());
    }
    if (item.getLanguage() != null) {
        setLanguage(item.getLanguage(), lang);
    }
    // LOM : Lifecycle
    if (StringHelper.containsNonWhitespace(item.getItemVersion())) {
        setLifecycleVersion(item.getItemVersion());
    }
    // LOM : Rights
    LicenseService lService = CoreSpringFactory.getImpl(LicenseService.class);
    ResourceLicense license = lService.loadLicense(item);
    if (license != null) {
        String licenseText = null;
        LicenseType licenseType = license.getLicenseType();
        if (lService.isFreetext(licenseType)) {
            licenseText = license.getFreetext();
        } else if (!lService.isNoLicense(licenseType)) {
            licenseText = license.getLicenseType().getName();
        }
        if (StringHelper.containsNonWhitespace(licenseText)) {
            setLicense(licenseText);
        }
        setOpenOLATMetadataCreator(license.getLicensor());
    }
    // LOM : classification
    if (StringHelper.containsNonWhitespace(item.getTaxonomicPath())) {
        setClassificationTaxonomy(item.getTaxonomicPath(), lang);
    }
    // QTI 2.1
    setQtiMetadataTool(item.getEditor(), null, item.getEditorVersion());
    if (assessmentItem != null) {
        List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
        List<String> interactionNames = new ArrayList<>(interactions.size());
        for (Interaction interaction : interactions) {
            interactionNames.add(interaction.getQtiClassName());
        }
        setQtiMetadataInteractionTypes(interactionNames);
    }
    // OpenOLAT
    if (item.getType() != null) {
        setOpenOLATMetadataQuestionType(item.getType().getType());
    } else {
        setOpenOLATMetadataQuestionType(null);
    }
    setOpenOLATMetadataIdentifier(item.getIdentifier());
    setOpenOLATMetadataDifficulty(item.getDifficulty());
    setOpenOLATMetadataDiscriminationIndex(item.getDifferentiation());
    setOpenOLATMetadataDistractors(item.getNumOfAnswerAlternatives());
    setOpenOLATMetadataStandardDeviation(item.getStdevDifficulty());
    setOpenOLATMetadataUsage(item.getUsage());
    setOpenOLATMetadataAssessmentType(item.getAssessmentType());
    setOpenOLATMetadataTopic(item.getTopic());
    setOpenOLATMetadataAdditionalInformations(item.getAdditionalInformations());
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ArrayList(java.util.ArrayList) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 3 with LicenseService

use of org.olat.core.commons.services.license.LicenseService in project OpenOLAT by OpenOLAT.

the class RepositoryEntryImportExport method addLicenseInformations.

private void addLicenseInformations(RepositoryEntryImport imp, RepositoryEntry re) {
    LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
    ResourceLicense license = licenseService.loadLicense(re.getOlatResource());
    if (license != null) {
        imp.setLicenseTypeKey(String.valueOf(license.getLicenseType().getKey()));
        imp.setLicenseTypeName(license.getLicenseType().getName());
        imp.setLicensor(license.getLicensor());
        imp.setLicenseText(LicenseUIFactory.getLicenseText(license));
    }
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 4 with LicenseService

use of org.olat.core.commons.services.license.LicenseService in project OpenOLAT by OpenOLAT.

the class MetaInfoFactory method getOrCreateLicense.

/**
 * Get the license of the MetaInfo or create a new default license:
 *
 * @param meta
 * @param itentity the current user
 * @return
 */
public License getOrCreateLicense(MetaInfo meta, Identity itentity) {
    LicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
    LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
    License license = getLicense(meta);
    if (license == null) {
        license = licenseService.createDefaultLicense(licenseHandler, itentity);
    }
    return license;
}
Also used : FolderLicenseHandler(org.olat.core.commons.modules.bc.FolderLicenseHandler) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) LicenseService(org.olat.core.commons.services.license.LicenseService) License(org.olat.core.commons.services.license.License)

Example 5 with LicenseService

use of org.olat.core.commons.services.license.LicenseService in project OpenOLAT by OpenOLAT.

the class MetaInfoFactory method getLicense.

/**
 * Get the license of the MetaInfo
 *
 * @param meta
 * @return the license or null if no license is stored in the MetaInfo
 */
public License getLicense(MetaInfo meta) {
    LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
    License license = null;
    boolean hasLicense = meta != null && StringHelper.containsNonWhitespace(meta.getLicenseTypeName());
    if (hasLicense) {
        String licenseTypeName = meta.getLicenseTypeName();
        LicenseType licenseType = licenseService.loadLicenseTypeByName(licenseTypeName);
        if (licenseType == null) {
            licenseType = licenseService.createLicenseType(licenseTypeName);
            licenseType.setText(meta.getLicenseText());
            licenseService.saveLicenseType(licenseType);
        }
        license = licenseService.createLicense(licenseType);
        license.setLicensor(meta.getLicensor());
        if (licenseService.isFreetext(licenseType)) {
            license.setFreetext(meta.getLicenseText());
        }
    }
    return license;
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) License(org.olat.core.commons.services.license.License) LicenseType(org.olat.core.commons.services.license.LicenseType)

Aggregations

LicenseService (org.olat.core.commons.services.license.LicenseService)20 LicenseType (org.olat.core.commons.services.license.LicenseType)14 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)8 License (org.olat.core.commons.services.license.License)6 FolderLicenseHandler (org.olat.core.commons.modules.bc.FolderLicenseHandler)4 ArrayList (java.util.ArrayList)2 LicenseHandler (org.olat.core.commons.services.license.LicenseHandler)2 LicenseModule (org.olat.core.commons.services.license.LicenseModule)2 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)2