Search in sources :

Example 1 with ClassificationType

use of org.olat.imsmd.xml.manifest.ClassificationType in project OpenOLAT by OpenOLAT.

the class ManifestMetadataBuilder method setClassificationTaxonomy.

/**
 * Set a taxonomy path of purpose "discipline"
 * @param taxonomyPath
 * @param lang
 */
public void setClassificationTaxonomy(String taxonomyPath, String lang) {
    ClassificationType classification = getClassification("discipline", lang, true);
    if (classification != null) {
        TaxonpathType taxonpathType = mdObjectFactory.createTaxonpathType();
        clearFromAny(TaxonpathType.class, classification.getContent());
        classification.getContent().add(mdObjectFactory.createTaxonpath(taxonpathType));
        taxonpathType.getTaxon().clear();
        SourceType sourceType = mdObjectFactory.createSourceType();
        sourceType.setLangstring(createString("Unkown", "en"));
        taxonpathType.setSource(sourceType);
        for (StringTokenizer tokenizer = new StringTokenizer(taxonomyPath, "/"); tokenizer.hasMoreTokens(); ) {
            String level = tokenizer.nextToken();
            TaxonType taxonType = mdObjectFactory.createTaxonType();
            EntryType entryType = mdObjectFactory.createEntryType();
            createOrUpdateFirstLangstring(entryType.getLangstring(), level, lang);
            taxonType.setEntry(entryType);
            taxonpathType.getTaxon().add(taxonType);
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) EntryType(org.olat.imsmd.xml.manifest.EntryType) TaxonType(org.olat.imsmd.xml.manifest.TaxonType) SourceType(org.olat.imsmd.xml.manifest.SourceType) TaxonpathType(org.olat.imsmd.xml.manifest.TaxonpathType) ClassificationType(org.olat.imsmd.xml.manifest.ClassificationType)

Example 2 with ClassificationType

use of org.olat.imsmd.xml.manifest.ClassificationType in project openolat by klemens.

the class ManifestMetadataBuilder method setClassificationTaxonomy.

/**
 * Set a taxonomy path of purpose "discipline"
 * @param taxonomyPath
 * @param lang
 */
public void setClassificationTaxonomy(String taxonomyPath, String lang) {
    ClassificationType classification = getClassification("discipline", lang, true);
    if (classification != null) {
        TaxonpathType taxonpathType = mdObjectFactory.createTaxonpathType();
        clearFromAny(TaxonpathType.class, classification.getContent());
        classification.getContent().add(mdObjectFactory.createTaxonpath(taxonpathType));
        taxonpathType.getTaxon().clear();
        SourceType sourceType = mdObjectFactory.createSourceType();
        sourceType.setLangstring(createString("Unkown", "en"));
        taxonpathType.setSource(sourceType);
        for (StringTokenizer tokenizer = new StringTokenizer(taxonomyPath, "/"); tokenizer.hasMoreTokens(); ) {
            String level = tokenizer.nextToken();
            TaxonType taxonType = mdObjectFactory.createTaxonType();
            EntryType entryType = mdObjectFactory.createEntryType();
            createOrUpdateFirstLangstring(entryType.getLangstring(), level, lang);
            taxonType.setEntry(entryType);
            taxonpathType.getTaxon().add(taxonType);
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) EntryType(org.olat.imsmd.xml.manifest.EntryType) TaxonType(org.olat.imsmd.xml.manifest.TaxonType) SourceType(org.olat.imsmd.xml.manifest.SourceType) TaxonpathType(org.olat.imsmd.xml.manifest.TaxonpathType) ClassificationType(org.olat.imsmd.xml.manifest.ClassificationType)

Example 3 with ClassificationType

use of org.olat.imsmd.xml.manifest.ClassificationType in project OpenOLAT by OpenOLAT.

the class ManifestMetadataBuilder method getClassificationTaxonomy.

public String getClassificationTaxonomy() {
    StringBuilder sb = new StringBuilder();
    ClassificationType classification = getClassification("discipline", null, false);
    if (classification != null) {
        TaxonpathType taxonpath = getFromAny(TaxonpathType.class, classification.getContent());
        if (taxonpath != null) {
            List<TaxonType> taxons = taxonpath.getTaxon();
            if (taxons != null) {
                for (TaxonType taxon : taxons) {
                    if (taxon.getEntry() != null && taxon.getEntry().getLangstring().size() > 0) {
                        LangstringType value = taxon.getEntry().getLangstring().get(0);
                        if (value != null && value.getValue() != null) {
                            sb.append("/").append(value.getValue());
                        }
                    }
                }
            }
        }
    }
    return sb.length() == 0 ? null : sb.toString();
}
Also used : TaxonType(org.olat.imsmd.xml.manifest.TaxonType) LangstringType(org.olat.imsmd.xml.manifest.LangstringType) TaxonpathType(org.olat.imsmd.xml.manifest.TaxonpathType) ClassificationType(org.olat.imsmd.xml.manifest.ClassificationType)

Example 4 with ClassificationType

use of org.olat.imsmd.xml.manifest.ClassificationType in project OpenOLAT by OpenOLAT.

the class ManifestMetadataBuilder method getClassification.

public ClassificationType getClassification(String purpose, String lang, boolean create) {
    LomType lom = getLom(create);
    if (lom == null)
        return null;
    ClassificationType classification = null;
    List<ClassificationType> classifications = lom.getClassification();
    for (ClassificationType cl : classifications) {
        PurposeType purposeType = getFromAny(PurposeType.class, cl.getContent());
        if (purposeType != null && purposeType.getValue() != null && purposeType.getValue().getLangstring() != null) {
            String value = purposeType.getValue().getLangstring().getValue();
            if (value != null && value.equals(purpose)) {
                classification = cl;
                break;
            }
        }
    }
    if (classification == null && create) {
        classification = mdObjectFactory.createClassificationType();
        PurposeType purposeType = mdObjectFactory.createPurposeType();
        purposeType.setSource(createSource("LOMv1.0", lang));
        purposeType.setValue(createValue(purpose, lang));
        classification.getContent().add(mdObjectFactory.createPurpose(purposeType));
        lom.getClassification().add(classification);
    }
    return classification;
}
Also used : PurposeType(org.olat.imsmd.xml.manifest.PurposeType) ClassificationType(org.olat.imsmd.xml.manifest.ClassificationType) LomType(org.olat.imsmd.xml.manifest.LomType)

Example 5 with ClassificationType

use of org.olat.imsmd.xml.manifest.ClassificationType in project openolat by klemens.

the class ManifestMetadataBuilder method getClassificationTaxonomy.

public String getClassificationTaxonomy() {
    StringBuilder sb = new StringBuilder();
    ClassificationType classification = getClassification("discipline", null, false);
    if (classification != null) {
        TaxonpathType taxonpath = getFromAny(TaxonpathType.class, classification.getContent());
        if (taxonpath != null) {
            List<TaxonType> taxons = taxonpath.getTaxon();
            if (taxons != null) {
                for (TaxonType taxon : taxons) {
                    if (taxon.getEntry() != null && taxon.getEntry().getLangstring().size() > 0) {
                        LangstringType value = taxon.getEntry().getLangstring().get(0);
                        if (value != null && value.getValue() != null) {
                            sb.append("/").append(value.getValue());
                        }
                    }
                }
            }
        }
    }
    return sb.length() == 0 ? null : sb.toString();
}
Also used : TaxonType(org.olat.imsmd.xml.manifest.TaxonType) LangstringType(org.olat.imsmd.xml.manifest.LangstringType) TaxonpathType(org.olat.imsmd.xml.manifest.TaxonpathType) ClassificationType(org.olat.imsmd.xml.manifest.ClassificationType)

Aggregations

ClassificationType (org.olat.imsmd.xml.manifest.ClassificationType)6 TaxonType (org.olat.imsmd.xml.manifest.TaxonType)4 TaxonpathType (org.olat.imsmd.xml.manifest.TaxonpathType)4 StringTokenizer (java.util.StringTokenizer)2 EntryType (org.olat.imsmd.xml.manifest.EntryType)2 LangstringType (org.olat.imsmd.xml.manifest.LangstringType)2 LomType (org.olat.imsmd.xml.manifest.LomType)2 PurposeType (org.olat.imsmd.xml.manifest.PurposeType)2 SourceType (org.olat.imsmd.xml.manifest.SourceType)2