/** * @param code BASE Dublin Core automatically assigned class code. * @return class code as YCategoryRef. * @see <a href="http://oai.base-search.net/index.html#base-dc">BASE Dublin Core format description.</a> */ public static YCategoryRef fromBaseDdcInfered(String code) { return new YCategoryRef(YaddaIdConstants.CATEGORY_CLASS_BASE_DDC_INFERED, code); }
/** * @param code BASE Dublin Core manually assigned class code. * @return class code as YCategoryRef. * @see <a href="http://oai.base-search.net/index.html#base-dc">BASE Dublin Core format description.</a> */ public static YCategoryRef fromBaseDdcByHand(String code) { return new YCategoryRef(YaddaIdConstants.CATEGORY_CLASS_BASE_DDC_BY_HAND, code); }
private YCategoryRef categoryRef(String classificationId, String code) { if (StringUtils.isBlank(classificationId) || StringUtils.isBlank(code)) return null; else return new YCategoryRef(classificationId, code); } }
private YCategoryRef categoryRef(String classificationId, String code) { if (StringUtils.isBlank(classificationId) || StringUtils.isBlank(code)) return null; else return new YCategoryRef(classificationId, code); }
private void addDisciplines(List<YCategoryRef> yCategoryRefs, String property) { for (String discipline : property.split(",")) { YCategoryRef newDiscipline = new YCategoryRef(YModelUtils.OECD_CLASSIFICATION, discipline); if (yCategoryRefs.contains(newDiscipline)) { continue; } yCategoryRefs.add(newDiscipline); } }
private void prepareRootDisciplines(List<YCategoryRef> yCategoryRefs) { final Map<String, String> rootCategories = new LinkedHashMap<String, String>(); prepareRootCategories(yCategoryRefs, rootCategories); for (String code : rootCategories.keySet()) { yCategoryRefs.add(new YCategoryRef(YModelUtils.OECD_CLASSIFICATION, code)); } }
private void changeCategoryRef(YElement elementWithCode, final String from, YElement element, final String to) { final Map<String, String> rootCategories = new HashMap<String, String>(); changeCategoryRef(element, elementWithCode, from, to, rootCategories); for (String code : rootCategories.keySet()) { element.addCategoryRef(new YCategoryRef(to, code)); } }
private void appendDisciplines(ResourceData resource, YElement yElement) { for (String discipline : resource.getDisciplines()) { if (StringUtils.isNotEmpty(discipline)) { yElement.addCategoryRef(new YCategoryRef(DisciplineOfScience.CATEGORY_CLASSIFICATION, discipline)); } } }
/** * Creates a category reference given its classification id and category code. * If the id or code is empty or null, does not create a reference but returns null. * * @param classId identifier of the classification from which the category comes * @param code code of the category * @return created reference, or null if either parameter was empty or null */ public YCategoryRef categoryRef(String classId, String code) { if (empty(classId) || empty(code)) return null; return new YCategoryRef(classId, code); }
/** * Reads MSC categories from field [cc] and writes to yElement. * * @param src * @param yelement */ private void updateArticleCategories(ZentralBlattRecord src, YElement yelement) { if (!src.hasField("cc")) { return; } String[] categories = src.getField("cc").split(" "); for (String category : categories) { if (category.equals("-")) { continue; } if (category.charAt(0) == '*') { category = category.substring(1); } YCategoryRef catRef = new YCategoryRef(YConstants.EXT_CLASSIFICATION_MSC, category); yelement.addCategoryRef(catRef); } }
protected static List<YCategoryRef> sanitizeCategoryRef(YCategoryRef ref) { Pattern pattern = null; if (ClassificationIds.EXT_CLASSIFICATION_CLC.equals(ref.getClassification())) pattern = CLC_REF_PATTERN; else if (ClassificationIds.EXT_CLASSIFICATION_JEL.equals(ref.getClassification())) pattern = JEL_REF_PATTERN; else if (ClassificationIds.EXT_CLASSIFICATION_MSC.equals(ref.getClassification())) pattern = MSC_REF_PATTERN; else if (ClassificationIds.EXT_CLASSIFICATION_PACS.equals(ref.getClassification())) pattern = PACS_REF_PATTERN; else if (ClassificationIds.EXT_CLASSIFICATION_QICS.equals(ref.getClassification())) pattern = QICS_REF_PATTERN; else if (ClassificationIds.EXT_CLASSIFICATION_ZDM.equals(ref.getClassification())) pattern = ZDM_REF_PATTERN; else return Collections.singletonList(ref); String code = ref.getCode(); List<YCategoryRef> foundCodes = new ArrayList<YCategoryRef>(); Matcher matcher = pattern.matcher(code); while (true) { if (!matcher.find()) break; YCategoryRef found = new YCategoryRef(ref.getClassification(), matcher.group(1).replaceAll("\\p{Pd}", "-")); foundCodes.add(found); } return foundCodes; } }
private void updateCategoryRefs(YElement article, org.jdom.Element kg, String type) { List<org.jdom.Element> ks = JDOMHelper.getChildren(kg, "kwd"); for (org.jdom.Element k : ks) { String codeText = JDOMHelper.textOfElement(k).toText(); for (String code : findAllCategoryCodes(codeText, type)) { YCategoryRef ref = new YCategoryRef(type, code); article.addCategoryRef(ref); } } }
private void chengeCategoryRef(YElement element, final String to, final Map<String, String> rootCategories , final YCategoryRef yCategoryRefWithCode) { YCategoryRef yCategoryRefToModify = new YCategoryRef(); yCategoryRefToModify.setClassification(to); yCategoryRefToModify.setCode(yCategoryRefWithCode.getCode()); element.addCategoryRef(yCategoryRefToModify); addRootCategories(yCategoryRefToModify, rootCategories); }