@Override public Object fromString(String str) { Matcher m = RE.matcher(str); if (!m.matches()) { throw new IllegalArgumentException( String.format("%s does not match regular expression: %s", str, RE)); } KeywordInfo kw = new Keyword(m.group(1)); if (m.group(2) != null) { kw.setLanguage(m.group(2)); } if (m.group(3) != null) { kw.setVocabulary(m.group(3)); } return kw; }
/** * Helper method that adds some tests keywords to a layer group. The provided layer group name * should not be NULL, if the layer group cannot be found an exception will be throw. */ protected void addKeywordsToLayerGroup(String layerGroupName) { // create a list of keywords List<KeywordInfo> keywords = new ArrayList<>(); Keyword keyword1 = new Keyword("keyword1"); keyword1.setLanguage("en"); keyword1.setVocabulary("vocabulary1"); keywords.add(keyword1); Keyword keyword2 = new Keyword("keyword2"); keyword2.setLanguage("pt"); keyword2.setVocabulary("vocabulary2"); keywords.add(keyword2); // add keywords to a layer group LayerGroupInfo layerGroup = getCatalog().getLayerGroupByName(layerGroupName); if (layerGroup == null) { // targeted layer group doesn't exists throw new RuntimeException( String.format("Layer group '%s' doesn't exists.", layerGroupName)); } layerGroup.getKeywords().addAll(keywords); getCatalog().save(layerGroup); }
@org.junit.Test public void testKeywordVocab() throws Exception { FeatureTypeInfo lines = getFeatureTypeInfo(MockData.LINES); Keyword kw = new Keyword("foo"); kw.setVocabulary("bar"); lines.getKeywords().add(kw); getCatalog().save(lines); WMSInfo wms = getGeoServer().getService(WMSInfo.class); kw = new Keyword("baz"); kw.setVocabulary("bar"); wms.getKeywords().add(kw); getGeoServer().save(wms); String linesName = MockData.LINES.getPrefix() + ":" + MockData.LINES.getLocalPart(); Document doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.3.0", true); String xpath = "//wms:Layer[wms:Name='" + linesName + "']/wms:KeywordList/wms:Keyword[@vocabulary='bar']"; assertXpathExists(xpath, doc); assertXpathEvaluatesTo("foo", xpath, doc); xpath = "//wms:Service/wms:KeywordList/wms:Keyword[@vocabulary='bar']"; assertXpathExists(xpath, doc); assertXpathEvaluatesTo("baz", xpath, doc); }
if (keywords != null) { for (String kw : keywords) { service.getKeywords().add(new Keyword(kw));
Keyword keyword1 = new Keyword("keyword1"); keyword1.setLanguage("en"); keyword1.setVocabulary("vocabulary1"); Keyword keyword2 = new Keyword("keyword2"); keyword2.setLanguage("pt"); keyword2.setVocabulary("vocabulary2");
continue; ftinfo.getKeywords().add(new Keyword(kw));
Keyword keyword1 = new Keyword("keyword1"); keyword1.setLanguage("en"); keyword1.setVocabulary("vocabulary1"); Keyword keyword2 = new Keyword("keyword2"); keyword2.setLanguage("pt"); keyword2.setVocabulary("vocabulary2");
cinfo.setName(specifiedName); cinfo.setTitle(specifiedName); cinfo.getKeywords().add(new Keyword(specifiedName)); } else { String name = reader.getGridCoverageNames()[0]; cinfo.setName(name); cinfo.setTitle(name); cinfo.getKeywords().add(new Keyword(name)); cinfo.getKeywords().add(new Keyword("WCS")); cinfo.getKeywords().add(new Keyword(format.getName()));
@Test public void testFullTextSearchAddedKeyword() { ft.getKeywords().add(new Keyword("air_temp")); ft.getKeywords().add(new Keyword("temperatureAir")); l.setResource(ft); addLayer(); LayerInfo lproxy = catalog.getLayer(l.getId()); FeatureTypeInfo ftproxy = (FeatureTypeInfo) lproxy.getResource(); ftproxy.getKeywords().add(new Keyword("newKeyword")); catalog.save(ftproxy); Filter filter = Predicates.fullTextSearch("newKeyword"); assertEquals(newHashSet(ftproxy), asSet(catalog.list(FeatureTypeInfo.class, filter))); assertEquals(newHashSet(lproxy), asSet(catalog.list(LayerInfo.class, filter))); }
coverage.setDescription(cInfoReader.description()); for (String kw : cInfoReader.keywords()) { coverage.getKeywords().add(new Keyword(kw));
@Test public void testMetadataFromFeatueSource() throws Exception { CatalogBuilder cb = new CatalogBuilder(getCatalog()); cb.setStore(cb.buildDataStore("fooStore")); FeatureType ft = createMock(FeatureType.class); expect(ft.getName()).andReturn(new NameImpl("foo")).anyTimes(); expect(ft.getCoordinateReferenceSystem()).andReturn(null).anyTimes(); expect(ft.getGeometryDescriptor()).andReturn(null).anyTimes(); replay(ft); ResourceInfo rInfo = createMock(ResourceInfo.class); expect(rInfo.getTitle()).andReturn("foo title"); expect(rInfo.getDescription()).andReturn("foo description"); expect(rInfo.getKeywords()) .andReturn(new LinkedHashSet<String>(Arrays.asList("foo", "bar", "baz", ""))) .anyTimes(); replay(rInfo); FeatureSource fs = createMock(FeatureSource.class); expect(fs.getSchema()).andReturn(ft).anyTimes(); expect(fs.getInfo()).andReturn(rInfo).anyTimes(); expect(fs.getName()).andReturn(ft.getName()).anyTimes(); replay(fs); FeatureTypeInfo ftInfo = cb.buildFeatureType(fs); assertEquals("foo title", ftInfo.getTitle()); assertEquals("foo description", ftInfo.getDescription()); assertTrue(ftInfo.getKeywords().contains(new Keyword("foo"))); assertTrue(ftInfo.getKeywords().contains(new Keyword("bar"))); assertTrue(ftInfo.getKeywords().contains(new Keyword("baz"))); }
for (String kw : layer.getKeywords()) { if (kw != null) { wli.getKeywords().add(new Keyword(kw));
for (String kw : layer.getKeywords()) { if (kw != null) { wli.getKeywords().add(new Keyword(kw));
expect(r.getKeywords()).andReturn((List) Arrays.asList(new Keyword(name))).anyTimes(); expect(r.isEnabled()).andReturn(true).anyTimes(); expect(r.isAdvertised()).andReturn(true).anyTimes();
coverage.setEnabled(true); coverage.getAlias().add("alias"); coverage.getKeywords().add(new Keyword("key")); MetadataLinkInfoImpl metadataLink = new MetadataLinkInfoImpl(); metadataLink.setAbout("about");
ft2 = catalog.getFeatureType(ft2.getId()); ft3 = catalog.getFeatureType(ft3.getId()); ft1.getKeywords().add(new Keyword("keyword1")); ft1.getKeywords().add(new Keyword("keyword2")); ft1.getKeywords().add(new Keyword("ft1")); ft1.setDescription("ft1 description"); catalog.save(ft1); ft2.getKeywords().add(new Keyword("keyword1")); ft2.getKeywords().add(new Keyword("keyword1")); ft2.setDescription("ft2"); catalog.save(ft2); ft3.getKeywords().add(new Keyword("ft3")); ft3.getKeywords().add(new Keyword("ft3")); ft3.setDescription("FT3"); catalog.save(ft3); factory.literal(new Keyword("keyword1")), factory.property("keywords"), true, factory.literal(new Keyword("keyword1")), factory.property("keywords"), true, factory.literal(new Keyword("keyword1")), factory.property("keywords"), true, values.add(new Keyword("keyword1"));
featureType.setAbstract(ftInfoReader.abstrct()); for (String kw : ftInfoReader.keywords()) { featureType.getKeywords().add(new Keyword(kw));
@Test public void testAddFeatureType() { assertTrue(catalog.getFeatureTypes().isEmpty()); addFeatureType(); assertEquals(1, catalog.getFeatureTypes().size()); FeatureTypeInfo ft2 = catalog.getFactory().createFeatureType(); try { catalog.add(ft2); fail("adding with no name should throw exception"); } catch (Exception e) { } ft2.setName("ft2Name"); try { catalog.add(ft2); fail("adding with no store should throw exception"); } catch (Exception e) { } ft2.setStore(ds); ft2.getKeywords().add(new Keyword("keyword")); catalog.add(ft2); FeatureTypeInfo ft3 = catalog.getFactory().createFeatureType(); ft3.setName("ft3Name"); try { catalog.getFeatureTypes().add(ft3); fail("adding directly should throw an exception"); } catch (Exception e) { } }