private static void elementToSecurityConstraints(Element element, RetsConfig config) { if (element == null) { config.setSecurityConstraints(new ArrayList()); return; } List securityConstraints = new ArrayList(); List children = element.getChildren(GROUP_RULES); for (int i = 0; i < children.size(); i++) { Element child = (Element) children.get(i); String groupName = child.getAttributeValue(GROUP); GroupRules groupRules = new GroupRules(groupName); List grandChildren = child.getChildren(); for (int j = 0; j < grandChildren.size(); j++) { Element grandChild = (Element) grandChildren.get(j); RuleDescription ruleDescription = new RuleDescription(); if (grandChild.getName().equals(INCLUDE_RULE)) { ruleDescription.setType(RuleDescription.INCLUDE); } else if (grandChild.getName().equals(EXCLUDE_RULE)) { ruleDescription.setType(RuleDescription.EXCLUDE); } else { LOG.warn("Unknown rule" + grandChild.toString()); continue; } ruleDescription.setResource(grandChild.getAttributeValue(RESOURCE)); ruleDescription.setRetsClass(grandChild.getAttributeValue(CLASS)); String systemNamesText = grandChild.getChildTextNormalize(SYSTEM_NAMES); String[] systemNamesArray = StringUtils.split(systemNamesText, " "); ruleDescription.setSystemNames(Arrays.asList(systemNamesArray)); groupRules.addRule(ruleDescription); } securityConstraints.add(groupRules); } config.setSecurityConstraints(securityConstraints); }
private void _convert() throws Exception { List<?> list = standard_name_table.getChildren("entry"); for (Iterator<?> iterator = list.iterator(); iterator.hasNext(); ) { Element ele = (Element) iterator.next(); numEntries++; String id = ele.getAttribute("id").getValue().trim(); String canonicalUnits = ele.getChildTextNormalize("canonical_units"); String grib = ele.getChildTextNormalize("grib"); String amip = ele.getChildTextNormalize("amip"); String description = ele.getChildTextNormalize("description"); String prefLabel = id.replace('_', ' '); URI conceptUri = URI.create(namespace + id); SKOSConcept concept = dataFactory.getSKOSConcept(conceptUri); concepts.add(concept); // skos:narrower objectRelationAssertions.add( dataFactory.getSKOSObjectRelationAssertion( topConcept, dataFactory.getSKOSNarrowerProperty(), concept)); // skos:prefLabel dataRelationAssertions.add( dataFactory.getSKOSDataRelationAssertion( concept, dataFactory.getSKOSPrefLabelProperty(), prefLabel)); //////////////////////////////////////////////// // OWL API stuff _addOwlChange(conceptUri, id, description, canonicalUnits, grib, amip); } props.put("entries", String.valueOf(numEntries)); props.put("concepts", String.valueOf(concepts.size())); allEntities.add(conceptScheme); allEntities.addAll(concepts); List<SKOSChange> skosChanges = new ArrayList<SKOSChange>(); // entities: List<SKOSEntityAssertion> entityAssertions = dataFactory.getSKOSEntityAssertions(allEntities); for (SKOSEntityAssertion ass : entityAssertions) { skosChanges.add(new AddAssertion(dataset, ass)); } // skos:inScheme objectRelationAssertions.addAll( dataFactory.getSKOSObjectRelationAssertions( concepts, dataFactory.getSKOSInSchemeProperty(), conceptScheme)); // object relations: for (SKOSObjectRelationAssertion assertion : objectRelationAssertions) { skosChanges.add(new AddAssertion(dataset, assertion)); } // data relations: for (SKOSDataRelationAssertion assertion : dataRelationAssertions) { skosChanges.add(new AddAssertion(dataset, assertion)); } manager.applyChanges(skosChanges); //////////////////////////////////////////////////// // OWL API assertions owlManager.applyChanges(owlChanges); }