Search in sources :

Example 1 with KeywordType

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

the class ManifestMetadataBuilder method setGeneralKeywords.

public void setGeneralKeywords(String keywords, String lang) {
    GeneralType general = getGeneral(true);
    if (general != null) {
        clearFromAny(KeywordType.class, general.getContent());
        for (StringTokenizer tokenizer = new StringTokenizer(keywords, " "); tokenizer.hasMoreTokens(); ) {
            String keyword = tokenizer.nextToken();
            KeywordType type = mdObjectFactory.createKeywordType();
            general.getContent().add(mdObjectFactory.createKeyword(type));
            createOrUpdateFirstLangstring(type.getLangstring(), keyword, lang);
        }
    }
}
Also used : KeywordType(org.olat.imsmd.xml.manifest.KeywordType) StringTokenizer(java.util.StringTokenizer) GeneralType(org.olat.imsmd.xml.manifest.GeneralType)

Example 2 with KeywordType

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

the class ManifestMetadataBuilder method getGeneralKeywords.

public String getGeneralKeywords() {
    GeneralType general = getGeneral(false);
    if (general != null) {
        StringBuilder keywords = new StringBuilder();
        for (Object any : general.getContent()) {
            if (any instanceof JAXBElement<?> && ((JAXBElement<?>) any).getValue().getClass().equals(KeywordType.class)) {
                KeywordType keywordType = (KeywordType) ((JAXBElement<?>) any).getValue();
                List<LangstringType> langStrings = keywordType.getLangstring();
                for (LangstringType langString : langStrings) {
                    String keyword = langString.getValue();
                    if (keywords.length() > 0)
                        keywords.append(" ");
                    keywords.append(keyword);
                }
            }
        }
        return keywords.toString();
    }
    return null;
}
Also used : KeywordType(org.olat.imsmd.xml.manifest.KeywordType) LangstringType(org.olat.imsmd.xml.manifest.LangstringType) GeneralType(org.olat.imsmd.xml.manifest.GeneralType)

Example 3 with KeywordType

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

the class ManifestMetadataBuilder method getGeneralKeywords.

public String getGeneralKeywords() {
    GeneralType general = getGeneral(false);
    if (general != null) {
        StringBuilder keywords = new StringBuilder();
        for (Object any : general.getContent()) {
            if (any instanceof JAXBElement<?> && ((JAXBElement<?>) any).getValue().getClass().equals(KeywordType.class)) {
                KeywordType keywordType = (KeywordType) ((JAXBElement<?>) any).getValue();
                List<LangstringType> langStrings = keywordType.getLangstring();
                for (LangstringType langString : langStrings) {
                    String keyword = langString.getValue();
                    if (keywords.length() > 0)
                        keywords.append(" ");
                    keywords.append(keyword);
                }
            }
        }
        return keywords.toString();
    }
    return null;
}
Also used : KeywordType(org.olat.imsmd.xml.manifest.KeywordType) LangstringType(org.olat.imsmd.xml.manifest.LangstringType) GeneralType(org.olat.imsmd.xml.manifest.GeneralType)

Example 4 with KeywordType

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

the class ManifestMetadataBuilder method setGeneralKeywords.

public void setGeneralKeywords(String keywords, String lang) {
    GeneralType general = getGeneral(true);
    if (general != null) {
        clearFromAny(KeywordType.class, general.getContent());
        for (StringTokenizer tokenizer = new StringTokenizer(keywords, " "); tokenizer.hasMoreTokens(); ) {
            String keyword = tokenizer.nextToken();
            KeywordType type = mdObjectFactory.createKeywordType();
            general.getContent().add(mdObjectFactory.createKeyword(type));
            createOrUpdateFirstLangstring(type.getLangstring(), keyword, lang);
        }
    }
}
Also used : KeywordType(org.olat.imsmd.xml.manifest.KeywordType) StringTokenizer(java.util.StringTokenizer) GeneralType(org.olat.imsmd.xml.manifest.GeneralType)

Aggregations

GeneralType (org.olat.imsmd.xml.manifest.GeneralType)4 KeywordType (org.olat.imsmd.xml.manifest.KeywordType)4 StringTokenizer (java.util.StringTokenizer)2 LangstringType (org.olat.imsmd.xml.manifest.LangstringType)2