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());
}
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));
}
}
use of org.olat.core.commons.services.license.LicenseService in project openolat by klemens.
the class LicenseUIFactory method getLicenseText.
public static String getLicenseText(License license) {
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
String licenseText = "";
if (license != null && license.getLicenseType() != null) {
LicenseType licenseType = license.getLicenseType();
if (licenseService.isFreetext(licenseType) && StringHelper.containsNonWhitespace(license.getFreetext())) {
licenseText = license.getFreetext();
} else if (StringHelper.containsNonWhitespace(licenseType.getText())) {
licenseText = licenseType.getText();
}
}
return licenseText;
}
use of org.olat.core.commons.services.license.LicenseService in project openolat by klemens.
the class LicenseUIFactory method updateVisibility.
public static void updateVisibility(SingleSelection licenseEl, TextElement licensorEl, TextElement licenseFreetextEl) {
boolean licenseSelected = false;
boolean freetextSelected = false;
if (licenseEl != null && licenseEl.isOneSelected()) {
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
String selectedKey = licenseEl.getSelectedKey();
LicenseType licenseType = licenseService.loadLicenseTypeByKey(selectedKey);
licenseSelected = !licenseService.isNoLicense(licenseType);
freetextSelected = licenseService.isFreetext(licenseType);
}
if (licensorEl != null) {
licensorEl.setVisible(licenseSelected);
}
if (licenseFreetextEl != null) {
licenseFreetextEl.setVisible(freetextSelected);
}
}
use of org.olat.core.commons.services.license.LicenseService in project openolat by klemens.
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());
}
Aggregations