List of usage examples for java.util Locale GERMAN
Locale GERMAN
To view the source code for java.util Locale GERMAN.
Click Source Link
From source file:software.coolstuff.springframework.owncloud.service.impl.rest.OwncloudRestResourceServiceTest.java
@Override protected void prepare_createDirectory_NOK_AlreadyExistsAsFile(URI uri) throws Exception { OwncloudTestFileResourceImpl existingResource = OwncloudTestFileResourceImpl.fileBuilder() .owncloudResource(//from w ww . jav a 2 s .c o m OwncloudTestResourceImpl.builder().href(uri).mediaType(MediaType.TEXT_PLAIN).build()) .testFileContent("No matter what content is in the existing Resource").build(); ArrayList<DavResource> result = Lists.newArrayList(createDavResourceFrom(existingResource, Locale.GERMAN)); Mockito.when(sardine.list(getResourcePath(uri), 0)).thenReturn(result); }
From source file:software.coolstuff.springframework.owncloud.service.impl.rest.OwncloudRestResourceServiceTest.java
@Override protected void prepare_createDirectory_OK_AlreadyExistsAsDirectory(OwncloudTestResourceImpl expected) throws Exception { ArrayList<DavResource> result = Lists.newArrayList(createDavResourceFrom(expected, Locale.GERMAN)); Mockito.when(sardine.list(getResourcePath(expected.getHref()), 0)).thenReturn(result); }
From source file:be.fedict.eid.tsl.BelgianTrustServiceListFactory.java
private static void setupTSL(TrustServiceList trustServiceList) { // scheme operator name trustServiceList.setSchemeOperatorName("FPS Economy, SMEs, Self-employed and Energy - Quality and Safety", Locale.ENGLISH);/* ww w .j a v a2 s . c o m*/ trustServiceList.setSchemeOperatorName( "FOD Economie, KMO, Middenstand en Energie - Kwaliteit en Veiligheid", new Locale("nl")); trustServiceList.setSchemeOperatorName( "SPF Economie, PME, Classes moyennes et Energie - Qualit et Scurit", Locale.FRENCH); trustServiceList.setSchemeOperatorName( "FD Wirtschaft, KMU, Mittelstand und Energie - Qualitt und Sicherheit", Locale.GERMAN); // scheme operator postal address PostalAddressType schemeOperatorPostalAddress = new PostalAddressType(); schemeOperatorPostalAddress.setStreetAddress("NG III - Koning Albert II-laan 16"); schemeOperatorPostalAddress.setLocality("Brussels"); schemeOperatorPostalAddress.setStateOrProvince("Brussels"); schemeOperatorPostalAddress.setPostalCode("1000"); schemeOperatorPostalAddress.setCountryName("BE"); // this one containing // an EU country // code trustServiceList.setSchemeOperatorPostalAddress(schemeOperatorPostalAddress, Locale.ENGLISH); schemeOperatorPostalAddress.setStreetAddress("NG III - Koning Albert II-laan 16"); schemeOperatorPostalAddress.setLocality("Brussel"); schemeOperatorPostalAddress.setStateOrProvince("Brussel"); schemeOperatorPostalAddress.setPostalCode("1000"); schemeOperatorPostalAddress.setCountryName("BE"); // this one containing // an EU country // code trustServiceList.setSchemeOperatorPostalAddress(schemeOperatorPostalAddress, new Locale("nl")); // scheme operator electronic address trustServiceList.setSchemeOperatorElectronicAddresses(Locale.ENGLISH, "http://economie.fgov.be"); trustServiceList.setSchemeOperatorElectronicAddresses(Locale.ENGLISH, "mailto:be.sign@economie.fgov.be"); // scheme name trustServiceList.setSchemeName( "BE:Supervision/Accreditation Status List of certification services from Certification Service Providers, which are supervised/accredited by the referenced Scheme Operator's Member State for compliance with the relevant provisions laid down in Directive 1999/93/EC of the European Parliament and of the Council of 13 December 1999 on a Community framework for electronic signatures.", Locale.ENGLISH); // scheme information URIs trustServiceList.addSchemeInformationUri("http://tsl.belgium.be/", Locale.ENGLISH); // trustServiceList.addSchemeInformationUri("http://tsl.belgium.be/nl/", // new Locale("nl")); // trustServiceList.addSchemeInformationUri("http://tsl.belgium.be/fr/", // Locale.FRENCH); // status determination approach trustServiceList.setStatusDeterminationApproach(TrustServiceList.STATUS_DETERMINATION_APPROPRIATE); // scheme type /* * The Scheme Type URIs can actually be visited. We should provide some * information to ETSI for the BE schemerules. */ trustServiceList.addSchemeType(TrustServiceList.SCHEME_RULE_COMMON, Locale.ENGLISH); /* * The BE schemerules MUSH be provided. We can add extra paths for * language. For example: http:// * uri.etsi.org/TrstSvc/eSigDir-1999-93-EC-TrustedList/schemerules/BE/nl */ trustServiceList.addSchemeType("http://uri.etsi.org/TrstSvc/TrustedList/schemerules/BE", Locale.ENGLISH); // scheme territory trustServiceList.setSchemeTerritory("BE"); // legal notice trustServiceList.addLegalNotice( "The applicable legal framework for the present TSL implementation of the Trusted List of supervised/accredited Certification Service Providers for Belgium is Directive 1999/93/EC of the European Parliament and of the Council of 13 December 1999 on a Community framework for electronic signatures and its implementation in Belgian laws. The applicable legal national framework is the Belgian CSP act of 9 July 2001 to create a legal framework for the usage of electronic signatures and certification services.", Locale.ENGLISH); // historical information period /* * Volgens de wet van 9 JULI 2001. Wet houdende vaststelling van * bepaalde regels in verband met het juridisch kader voor elektronische * handtekeningen en certificatiediensten: Bijlage II - punt i) alle * relevante informatie over een gekwalificeerd certificaat te * registreren gedurende de nuttige termijn van dertig jaar, in het * bijzonder om een certificatiebewijs te kunnen voorleggen bij * gerechtelijke procedures. */ trustServiceList.setHistoricalInformationPeriod(21845 * 3); trustServiceList.addDistributionPoint("http://tsl.belgium.be/tsl-be.xml"); }
From source file:de.geeksfactory.opacclient.apis.Bibliotheca.java
protected DetailledItem parse_result(String html) { Document doc = Jsoup.parse(html); doc.setBaseUri(opac_url);/*from ww w . j av a 2 s.c o m*/ DetailledItem result = new DetailledItem(); if (doc.select(".detail_cover img").size() == 1) { result.setCover(doc.select(".detail_cover img").get(0).attr("src")); } result.setTitle(doc.select(".detail_titel").text()); Elements detailtrs = doc.select(".detailzeile table tr"); for (int i = 0; i < detailtrs.size(); i++) { Element tr = detailtrs.get(i); if (tr.child(0).hasClass("detail_feld")) { String title = tr.child(0).text(); String content = tr.child(1).text(); if (title.equals("Gesamtwerk:") || title.equals("Erschienen in:")) { try { if (tr.child(1).select("a").size() > 0) { Element link = tr.child(1).select("a").first(); List<NameValuePair> query = URLEncodedUtils.parse(new URI(link.absUrl("href")), "UTF-8"); for (NameValuePair q : query) { if (q.getName().equals("MedienNr")) { result.setCollectionId(q.getValue()); } } } } catch (URISyntaxException e) { } } else { if (content.contains("hier klicken") && tr.child(1).select("a").size() > 0) { content += " " + tr.child(1).select("a").first().attr("href"); } result.addDetail(new Detail(title, content)); } } } Elements detailcenterlinks = doc.select(".detailzeile_center a.detail_link"); for (int i = 0; i < detailcenterlinks.size(); i++) { Element a = detailcenterlinks.get(i); result.addDetail(new Detail(a.text().trim(), a.absUrl("href"))); } try { JSONObject copymap = new JSONObject(); if (data.has("copiestable")) { copymap = data.getJSONObject("copiestable"); } else { Elements ths = doc.select(".exemplartab .exemplarmenubar th"); for (int i = 0; i < ths.size(); i++) { Element th = ths.get(i); String head = th.text().trim(); if (head.equals("Zweigstelle")) { copymap.put("branch", i); } else if (head.equals("Abteilung")) { copymap.put("department", i); } else if (head.equals("Bereich") || head.equals("Standort")) { copymap.put("location", i); } else if (head.equals("Signatur")) { copymap.put("signature", i); } else if (head.equals("Barcode") || head.equals("Medien-Nummer")) { copymap.put("barcode", i); } else if (head.equals("Status")) { copymap.put("status", i); } else if (head.equals("Frist") || head.matches("Verf.+gbar")) { copymap.put("returndate", i); } else if (head.equals("Vorbestellungen") || head.equals("Reservierungen")) { copymap.put("reservations", i); } } } Elements exemplartrs = doc.select(".exemplartab .tabExemplar, .exemplartab .tabExemplar_"); DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN); for (int i = 0; i < exemplartrs.size(); i++) { Element tr = exemplartrs.get(i); Copy copy = new Copy(); Iterator<?> keys = copymap.keys(); while (keys.hasNext()) { String key = (String) keys.next(); int index; try { index = copymap.has(key) ? copymap.getInt(key) : -1; } catch (JSONException e1) { index = -1; } if (index >= 0) { try { copy.set(key, tr.child(index).text(), fmt); } catch (IllegalArgumentException e) { e.printStackTrace(); } } } result.addCopy(copy); } } catch (Exception e) { e.printStackTrace(); } try { Elements bandtrs = doc.select("table .tabBand a"); for (int i = 0; i < bandtrs.size(); i++) { Element tr = bandtrs.get(i); Volume volume = new Volume(); volume.setId(tr.attr("href").split("=")[1]); volume.setTitle(tr.text()); result.addVolume(volume); } } catch (Exception e) { e.printStackTrace(); } if (doc.select(".detail_vorbest a").size() == 1) { result.setReservable(true); result.setReservation_info(doc.select(".detail_vorbest a").attr("href")); } return result; }
From source file:controllers.nwbib.Application.java
/** * @param q Query to search in all fields * @param person Query for a person associated with the resource * @param name Query for the resource name (title) * @param subject Query for the resource subject * @param id Query for the resource id//w w w .ja v a2 s .c o m * @param publisher Query for the resource publisher * @param issued Query for the resource issued year * @param medium Query for the resource medium * @param nwbibspatial Query for the resource nwbibspatial classification * @param nwbibsubject Query for the resource nwbibsubject classification * @param from The page start (offset of page of resource to return) * @param size The page size (size of page of resource to return) * @param owner Owner filter for resource queries * @param t Type filter for resource queries * @param field The facet field (the field to facet over) * @param sort Sorting order for results ("newest", "oldest", "" -> relevance) * @param set The set, overrides the default NWBib set if not empty * @param location A polygon describing the subject area of the resources * @param word A word, a concept from the hbz union catalog * @param corporation A corporation associated with the resource * @param raw A query string that's directly (unprocessed) passed to ES * @return The search results */ public static Promise<Result> facets(String q, String person, String name, String subject, String id, String publisher, String issued, String medium, String nwbibspatial, String nwbibsubject, int from, int size, String owner, String t, String field, String sort, String set, String location, String word, String corporation, String raw) { String key = String.format("facets.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s", field, q, person, name, id, publisher, set, location, word, corporation, raw, subject, issued, medium, nwbibspatial, nwbibsubject, owner, t); Result cachedResult = (Result) Cache.get(key); if (cachedResult != null) { return Promise.promise(() -> cachedResult); } String labelTemplate = "<span class='%s'/> %s (%s)"; Function<JsonNode, Pair<JsonNode, String>> toLabel = json -> { String term = json.get("term").asText(); int count = json.get("count").asInt(); String icon = Lobid.facetIcon(Arrays.asList(term), field); String label = Lobid.facetLabel(Arrays.asList(term), field, ""); String fullLabel = String.format(labelTemplate, icon, label, count); return Pair.of(json, fullLabel); }; Predicate<Pair<JsonNode, String>> labelled = pair -> { JsonNode json = pair.getLeft(); String label = pair.getRight(); int count = json.get("count").asInt(); return (!label.contains("http") || label.contains("nwbib")) && label.length() > String.format(labelTemplate, "", "", count).length(); }; Collator collator = Collator.getInstance(Locale.GERMAN); Comparator<Pair<JsonNode, String>> sorter = (p1, p2) -> { String t1 = p1.getLeft().get("term").asText(); String t2 = p2.getLeft().get("term").asText(); boolean t1Current = current(subject, medium, nwbibspatial, nwbibsubject, owner, t, field, t1, raw); boolean t2Current = current(subject, medium, nwbibspatial, nwbibsubject, owner, t, field, t2, raw); if (t1Current == t2Current) { if (!field.equals(ISSUED_FIELD)) { Integer c1 = p1.getLeft().get("count").asInt(); Integer c2 = p2.getLeft().get("count").asInt(); return c2.compareTo(c1); } String l1 = p1.getRight().substring(p1.getRight().lastIndexOf('>') + 1); String l2 = p2.getRight().substring(p2.getRight().lastIndexOf('>') + 1); return collator.compare(l1, l2); } return t1Current ? -1 : t2Current ? 1 : 0; }; Function<Pair<JsonNode, String>, String> toHtml = pair -> { JsonNode json = pair.getLeft(); String fullLabel = pair.getRight(); String term = json.get("term").asText(); if (field.equals(SUBJECT_LOCATION_FIELD)) { GeoPoint point = new GeoPoint(term); term = String.format("%s,%s", point.getLat(), point.getLon()); } String mediumQuery = !field.equals(MEDIUM_FIELD) // ? medium : queryParam(medium, term); String typeQuery = !field.equals(TYPE_FIELD) // ? t : queryParam(t, term); String ownerQuery = !field.equals(ITEM_FIELD) // ? owner : withoutAndOperator(queryParam(owner, term)); String nwbibsubjectQuery = !field.equals(NWBIB_SUBJECT_FIELD) // ? nwbibsubject : queryParam(nwbibsubject, term); String nwbibspatialQuery = !field.equals(NWBIB_SPATIAL_FIELD) // ? nwbibspatial : queryParam(nwbibspatial, term); String rawQuery = !field.equals(COVERAGE_FIELD) // ? raw : rawQueryParam(raw, term); String locationQuery = !field.equals(SUBJECT_LOCATION_FIELD) // ? location : term; String subjectQuery = !field.equals(SUBJECT_FIELD) // ? subject : queryParam(subject, term); String issuedQuery = !field.equals(ISSUED_FIELD) // ? issued : queryParam(issued, term); boolean current = current(subject, medium, nwbibspatial, nwbibsubject, owner, t, field, term, raw); String routeUrl = routes.Application.search(q, person, name, subjectQuery, id, publisher, issuedQuery, mediumQuery, nwbibspatialQuery, nwbibsubjectQuery, from, size, ownerQuery, typeQuery, sort(sort, nwbibspatialQuery, nwbibsubjectQuery, subjectQuery), false, set, locationQuery, word, corporation, rawQuery).url(); String result = String.format( "<li " + (current ? "class=\"active\"" : "") + "><a class=\"%s-facet-link\" href='%s'>" + "<input onclick=\"location.href='%s'\" class=\"facet-checkbox\" " + "type=\"checkbox\" %s> %s</input>" + "</a></li>", Math.abs(field.hashCode()), routeUrl, routeUrl, current ? "checked" : "", fullLabel); return result; }; Promise<Result> promise = Lobid.getFacets(q, person, name, subject, id, publisher, issued, medium, nwbibspatial, nwbibsubject, owner, field, t, set, location, word, corporation, raw).map(json -> { Stream<JsonNode> stream = StreamSupport.stream( Spliterators.spliteratorUnknownSize(json.findValue("entries").elements(), 0), false); if (field.equals(ITEM_FIELD)) { stream = preprocess(stream); } String labelKey = String.format( "facets-labels.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s", field, raw, q, person, name, id, publisher, set, word, corporation, subject, issued, medium, nwbibspatial, nwbibsubject, raw, field.equals(ITEM_FIELD) ? "" : owner, t, location); @SuppressWarnings("unchecked") List<Pair<JsonNode, String>> labelledFacets = (List<Pair<JsonNode, String>>) Cache .get(labelKey); if (labelledFacets == null) { labelledFacets = stream.map(toLabel).filter(labelled).collect(Collectors.toList()); Cache.set(labelKey, labelledFacets, ONE_DAY); } return labelledFacets.stream().sorted(sorter).map(toHtml).collect(Collectors.toList()); }).map(lis -> ok(String.join("\n", lis))); promise.onRedeem(r -> Cache.set(key, r, ONE_DAY)); return promise; }
From source file:de.geeksfactory.opacclient.apis.Zones.java
private DetailledItem parse_result(String id, String html) { Document doc = Jsoup.parse(html); DetailledItem result = new DetailledItem(); result.setTitle(""); boolean title_is_set = false; result.setId(id);/* w w w . j a v a2 s.c o m*/ String detailTrsQuery = version18 ? ".inRoundBox1 table table tr" : ".DetailDataCell table table:not(.inRecordHeader) tr"; Elements detailtrs1 = doc.select(detailTrsQuery); for (int i = 0; i < detailtrs1.size(); i++) { Element tr = detailtrs1.get(i); int s = tr.children().size(); if (tr.child(0).text().trim().equals("Titel") && !title_is_set) { result.setTitle(tr.child(s - 1).text().trim()); title_is_set = true; } else if (s > 1) { Element valchild = tr.child(s - 1); if (valchild.select("table").isEmpty()) { String val = valchild.text().trim(); if (val.length() > 0) { result.addDetail(new Detail(tr.child(0).text().trim(), val)); } } } } for (Element a : doc.select("a.SummaryActionLink")) { if (a.text().contains("Vormerken")) { result.setReservable(true); result.setReservation_info(a.attr("href")); } } Elements detaildiv = doc.select("div.record-item-new"); if (!detaildiv.isEmpty()) { for (int i = 0; i < detaildiv.size(); i++) { Element dd = detaildiv.get(i); String text = ""; for (Node node : dd.childNodes()) { if (node instanceof TextNode) { String snip = ((TextNode) node).text(); if (snip.length() > 0) { text += snip; } } else if (node instanceof Element) { if (((Element) node).tagName().equals("br")) { text += "\n"; } else { String snip = ((Element) node).text().trim(); if (snip.length() > 0) { text += snip; } } } } result.addDetail(new Detail("", text)); } } if (doc.select("span.z3988").size() > 0) { // Sometimes there is a <span class="Z3988"> item which provides // data in a standardized format. String z3988data = doc.select("span.z3988").first().attr("title").trim(); for (String pair : z3988data.split("&")) { String[] nv = pair.split("=", 2); if (nv.length == 2) { if (!nv[1].trim().equals("")) { if (nv[0].equals("rft.btitle") && result.getTitle().length() == 0) { result.setTitle(nv[1]); } else if (nv[0].equals("rft.atitle") && result.getTitle().length() == 0) { result.setTitle(nv[1]); } else if (nv[0].equals("rft.au")) { result.addDetail(new Detail("Author", nv[1])); } } } } } // Cover if (doc.select(".BookCover, .LargeBookCover").size() > 0) { result.setCover(doc.select(".BookCover, .LargeBookCover").first().attr("src")); } Elements copydivs = doc.select("div[id^=stock_]"); String pop = ""; for (int i = 0; i < copydivs.size(); i++) { Element div = copydivs.get(i); if (div.attr("id").startsWith("stock_head")) { pop = div.text().trim(); continue; } Copy copy = new Copy(); DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN); // This is getting very ugly - check if it is valid for libraries which are not Hamburg. // Seems to also work in Kiel (Zones 1.8, checked 10.10.2015) int j = 0; for (Node node : div.childNodes()) { try { if (node instanceof Element) { if (((Element) node).tag().getName().equals("br")) { copy.setBranch(pop); result.addCopy(copy); j = -1; } else if (((Element) node).tag().getName().equals("b") && j == 1) { copy.setLocation(((Element) node).text()); } else if (((Element) node).tag().getName().equals("b") && j > 1) { copy.setStatus(((Element) node).text()); } j++; } else if (node instanceof TextNode) { if (j == 0) { copy.setDepartment(((TextNode) node).text()); } if (j == 2) { copy.setBarcode(((TextNode) node).getWholeText().trim().split("\n")[0].trim()); } if (j == 6) { String text = ((TextNode) node).text().trim(); String date = text.substring(text.length() - 10); try { copy.setReturnDate(fmt.parseLocalDate(date)); } catch (IllegalArgumentException e) { e.printStackTrace(); } } j++; } } catch (Exception e) { e.printStackTrace(); } } } return result; }
From source file:unikn.dbis.univis.explorer.VExplorer.java
License:asdf
private void makeLanguageMenu() { german.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Locale locale = Locale.GERMAN; MessageResolver.setLocale(locale); whatLanguageLabel.setText(locale.getDisplayName(locale)); ComponentUtilities.repaintComponentTree(VExplorer.this); }/*from w w w. j a v a2 s . c o m*/ }); english.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Locale locale = Locale.ENGLISH; MessageResolver.setLocale(locale); whatLanguageLabel.setText(locale.getDisplayName(locale)); ComponentUtilities.repaintComponentTree(VExplorer.this); } }); newLanguage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(VExplorer.this.getContentPane(), languageMessage, languageTitle, 1); } }); final ButtonGroup languageGroup = new ButtonGroup(); german.setSelected(true); languageGroup.add(german); languageGroup.add(english); languageMenu.add(german); languageMenu.add(english); languageMenu.add(newLanguage); }
From source file:de.geeksfactory.opacclient.apis.BiBer1992.java
private DetailledItem parse_result(String html) { DetailledItem item = new DetailledItem(); Document document = Jsoup.parse(html); Elements rows = document.select("html body form table tr"); // Elements rows = document.select("html body div form table tr"); // Element rowReverseSubject = null; Detail detail = null;/*from w w w . j av a2 s .c o m*/ // prepare copiestable Copy copy_last_content = null; int copy_row = 0; String[] copy_keys = new String[] { "barcode", "branch", "department", "location", "status", "returndate", "reservations" }; int[] copy_map = new int[] { 3, 1, -1, 1, 4, -1, -1 }; try { JSONObject map = data.getJSONObject("copiestable"); for (int i = 0; i < copy_keys.length; i++) { if (map.has(copy_keys[i])) { copy_map[i] = map.getInt(copy_keys[i]); } } } catch (Exception e) { // "copiestable" is optional } DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN); // go through all rows for (Element row : rows) { Elements columns = row.children(); if (columns.size() == 2) { // HTML tag " " is encoded as 0xA0 String firstColumn = columns.get(0).text().replace("\u00a0", " ").trim(); String secondColumn = columns.get(1).text().replace("\u00a0", " ").trim(); if (firstColumn.length() > 0) { // 1st column is category if (firstColumn.equalsIgnoreCase("titel")) { detail = null; item.setTitle(secondColumn); } else { if (secondColumn.contains("hier klicken") && columns.get(1).select("a").size() > 0) { secondColumn += " " + columns.get(1).select("a").first().attr("href"); } detail = new Detail(firstColumn, secondColumn); item.getDetails().add(detail); } } else { // 1st column is empty, so it is an extension to last // category if (detail != null) { String content = detail.getContent() + "\n" + secondColumn; detail.setContent(content); } else { // detail==0, so it's the first row // check if there is an amazon image if (columns.get(0).select("a img[src]").size() > 0) { item.setCover(columns.get(0).select("a img").first().attr("src")); } } } } else if (columns.size() > 3) { // This is the second section: the copies in stock ("Exemplare") // With reverse layout: first row is headline, skipped via // (copy_row > 0) if (copy_row > 0) { Copy copy = new Copy(); for (int j = 0; j < copy_keys.length; j++) { int col = copy_map[j]; if (col > -1) { String text = ""; if (copy_keys[j].equals("branch")) { // for "Standort" only use ownText() to suppress // Link "Wegweiser" text = columns.get(col).ownText().replace("\u00a0", " ").trim(); } if (text.length() == 0) { // text of children text = columns.get(col).text().replace("\u00a0", " ").trim(); } if (text.length() == 0) { // empty table cell, take the one above // this is sometimes the case for "Standort" if (copy_keys[j].equals("status")) { // but do it not for Status text = " "; } else { if (copy_last_content != null) { text = copy_last_content.get(copy_keys[j]); } else { text = ""; } } } if (copy_keys[j].equals("reservations")) { text = text.replace("Vorgemerkt: ", "").replace("Vorbestellt: ", ""); } try { copy.set(copy_keys[j], text, fmt); } catch (IllegalArgumentException e) { e.printStackTrace(); } } } if (copy.getBranch() != null && copy.getLocation() != null && copy.getLocation().equals(copy.getBranch())) { copy.setLocation(null); } item.addCopy(copy); copy_last_content = copy; } // ignore 1st row copy_row++; } // if columns.size } // for rows item.setReservable(true); // We cannot check if media is reservable if (opacDir.contains("opax")) { if (document.select("input[type=checkbox]").size() > 0) { item.setReservation_info(document.select("input[type=checkbox]").first().attr("name")); } else if (document.select("a[href^=reserv" + opacSuffix + "]").size() > 0) { String href = document.select("a[href^=reserv" + opacSuffix + "]").first().attr("href"); item.setReservation_info(href.substring(href.indexOf("resF_"))); } else { item.setReservable(false); } } else { item.setReservation_info(document.select("input[name=ID]").attr("value")); } return item; }
From source file:de.geeksfactory.opacclient.apis.Pica.java
protected DetailledItem parse_result(String html) { Document doc = Jsoup.parse(html); doc.setBaseUri(opac_url);//from w w w. ja va 2s . c o m DetailledItem result = new DetailledItem(); for (Element a : doc.select("a[href*=PPN")) { Map<String, String> hrefq = getQueryParamsFirst(a.absUrl("href")); String ppn = hrefq.get("PPN"); result.setId(ppn); break; } // GET COVER if (doc.select("td.preslabel:contains(ISBN) + td.presvalue").size() > 0) { Element isbnElement = doc.select("td.preslabel:contains(ISBN) + td.presvalue").first(); String isbn = ""; for (Node child : isbnElement.childNodes()) { if (child instanceof TextNode) { isbn = ((TextNode) child).text().trim(); break; } } result.setCover(ISBNTools.getAmazonCoverURL(isbn, true)); } // GET TITLE AND SUBTITLE String titleAndSubtitle; Element titleAndSubtitleElem = null; String titleRegex = ".*(Titel|Aufsatz|Zeitschrift|Gesamttitel" + "|Title|Article|Periodical|Collective\\stitle" + "|Titre|Article|P.riodique|Titre\\sg.n.ral).*"; String selector = "td.preslabel:matches(" + titleRegex + ") + td.presvalue"; if (doc.select(selector).size() > 0) { titleAndSubtitleElem = doc.select(selector).first(); titleAndSubtitle = titleAndSubtitleElem.text().trim(); int slashPosition = Math.min(titleAndSubtitle.indexOf("/"), titleAndSubtitle.indexOf(":")); String title; if (slashPosition > 0) { title = titleAndSubtitle.substring(0, slashPosition).trim(); String subtitle = titleAndSubtitle.substring(slashPosition + 1).trim(); result.addDetail(new Detail(stringProvider.getString(StringProvider.SUBTITLE), subtitle)); } else { title = titleAndSubtitle; } result.setTitle(title); } else { result.setTitle(""); } // Details int line = 0; Elements lines = doc.select("td.preslabel + td.presvalue"); if (titleAndSubtitleElem != null) { lines.remove(titleAndSubtitleElem); } for (Element element : lines) { Element titleElem = element.firstElementSibling(); String detail = ""; if (element.select("div").size() > 1 && element.select("div").text().equals(element.text())) { boolean first = true; for (Element div : element.select("div")) { if (!div.text().replace("\u00a0", " ").trim().equals("")) { if (!first) { detail += "\n" + div.text().replace("\u00a0", " ").trim(); } else { detail += div.text().replace("\u00a0", " ").trim(); first = false; } } } } else { detail = element.text().replace("\u00a0", " ").trim(); } String title = titleElem.text().replace("\u00a0", " ").trim(); if (element.select("hr").size() > 0) // after the separator we get the copies { break; } if (detail.length() == 0 && title.length() == 0) { line++; continue; } if (title.contains(":")) { title = title.substring(0, title.indexOf(":")); // remove colon } result.addDetail(new Detail(title, detail)); if (element.select("a").size() == 1 && !element.select("a").get(0).text().trim().equals("")) { String url = element.select("a").first().absUrl("href"); if (!url.startsWith(opac_url)) { result.addDetail(new Detail(stringProvider.getString(StringProvider.LINK), url)); } } line++; } line++; // next line after separator // Copies Copy copy = new Copy(); String location = ""; // reservation info will be stored as JSON JSONArray reservationInfo = new JSONArray(); while (line < lines.size()) { Element element = lines.get(line); if (element.select("hr").size() == 0) { Element titleElem = element.firstElementSibling(); String detail = element.text().trim(); String title = titleElem.text().replace("\u00a0", " ").trim(); if (detail.length() == 0 && title.length() == 0) { line++; continue; } if (title.contains("Standort") || title.contains("Vorhanden in") || title.contains("Location")) { location += detail; } else if (title.contains("Sonderstandort")) { location += " - " + detail; } else if (title.contains("Systemstelle") || title.contains("Subject")) { copy.setDepartment(detail); } else if (title.contains("Fachnummer") || title.contains("locationnumber")) { copy.setLocation(detail); } else if (title.contains("Signatur") || title.contains("Shelf mark")) { copy.setShelfmark(detail); } else if (title.contains("Anmerkung")) { location += " (" + detail + ")"; } else if (title.contains("Link")) { result.addDetail(new Detail(title.replace(":", "").trim(), detail)); } else if (title.contains("Status") || title.contains("Ausleihinfo") || title.contains("Ausleihstatus") || title.contains("Request info")) { // Find return date Pattern pattern = Pattern.compile("(till|bis) (\\d{2}-\\d{2}-\\d{4})"); Matcher matcher = pattern.matcher(detail); if (matcher.find()) { DateTimeFormatter fmt = DateTimeFormat.forPattern("dd-MM-yyyy").withLocale(Locale.GERMAN); try { copy.setStatus(detail.substring(0, matcher.start() - 1).trim()); copy.setReturnDate(fmt.parseLocalDate(matcher.group(2))); } catch (IllegalArgumentException e) { e.printStackTrace(); copy.setStatus(detail); } } else { copy.setStatus(detail); } // Get reservation info if (element.select("a:has(img[src*=inline_arrow])").size() > 0) { Element a = element.select("a:has(img[src*=inline_arrow])").first(); boolean multipleCopies = a.text().matches(".*(Exemplare|Volume list).*"); JSONObject reservation = new JSONObject(); try { reservation.put("multi", multipleCopies); reservation.put("link", _extract_url(a.absUrl("href"))); reservation.put("desc", location); reservationInfo.put(reservation); } catch (JSONException e1) { e1.printStackTrace(); } result.setReservable(true); } } } else { copy.setBranch(location); result.addCopy(copy); location = ""; copy = new Copy(); } line++; } if (copy.notEmpty()) { copy.setBranch(location); result.addCopy(copy); } if (reservationInfo.length() == 0) { // No reservation info found yet, because we didn't find any copies. // If there is a reservation link somewhere in the rows we interpreted // as details, we still want to use it. if (doc.select("td a:has(img[src*=inline_arrow])").size() > 0) { Element a = doc.select("td a:has(img[src*=inline_arrow])").first(); boolean multipleCopies = a.text().matches(".*(Exemplare|Volume list).*"); JSONObject reservation = new JSONObject(); try { reservation.put("multi", multipleCopies); reservation.put("link", _extract_url(a.attr("href"))); reservation.put("desc", location); reservationInfo.put(reservation); } catch (JSONException e1) { e1.printStackTrace(); } result.setReservable(true); } } result.setReservation_info(reservationInfo.toString()); // Volumes if (doc.select("a[href^=FAM?PPN=]").size() > 0) { String href = doc.select("a[href^=FAM?PPN=]").attr("href"); String ppn = getQueryParamsFirst(href).get("PPN"); Map<String, String> data = new HashMap<>(); data.put("ppn", ppn); result.setVolumesearch(data); } return result; }
From source file:org.alfresco.repo.search.impl.lucene.ADMLuceneTest.java
public void setUp() throws Exception { dialect = (Dialect) ctx.getBean("dialect"); nodeService = (NodeService) ctx.getBean("dbNodeService"); dictionaryService = (DictionaryService) ctx.getBean("dictionaryService"); dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO"); luceneFTS = (FullTextSearchIndexer) ctx.getBean("LuceneFullTextSearchIndexer"); contentService = (ContentService) ctx.getBean("contentService"); queryRegisterComponent = (QueryRegisterComponent) ctx.getBean("queryRegisterComponent"); namespacePrefixResolver = (DictionaryNamespaceComponent) ctx.getBean("namespaceService"); transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); indexerAndSearcher = (IndexerAndSearcher) ctx.getBean("admLuceneIndexerAndSearcherFactory"); luceneConfig = (LuceneConfig) ctx.getBean("admLuceneIndexerAndSearcherFactory"); ((LuceneConfig) indexerAndSearcher).setMaxAtomicTransformationTime(1000000); transactionService = (TransactionService) ctx.getBean("transactionComponent"); retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper"); tenantService = (TenantService) ctx.getBean("tenantService"); queryEngine = (QueryEngine) ctx.getBean("adm.luceneQueryEngineImpl"); nodeBulkLoader = (NodeBulkLoader) ctx.getBean("nodeDAO"); serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); namespaceDao = (NamespaceDAO) ctx.getBean("namespaceDAO"); I18NUtil.setLocale(Locale.UK); this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); queryRegisterComponent.loadQueryCollection("testQueryRegister.xml"); assertEquals(true, ctx.isSingleton("LuceneFullTextSearchIndexer")); testTX = transactionService.getUserTransaction(); testTX.begin();//from ww w .jav a 2s. co m this.authenticationComponent.setSystemUserAsCurrentUser(); // load in the test model ClassLoader cl = BaseNodeServiceTest.class.getClassLoader(); InputStream modelStream = cl .getResourceAsStream("org/alfresco/repo/search/impl/lucene/LuceneTest_model.xml"); assertNotNull(modelStream); model = M2Model.createModel(modelStream); dictionaryDAO.registerListener(this); dictionaryDAO.reset(); assertNotNull(dictionaryDAO.getClass(testSuperType)); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); n1 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), testSuperType, getOrderProperties()).getChildRef(); nodeService.setProperty(n1, QName.createQName("{namespace}property-1"), "ValueOne"); n2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}two"), testSuperType, getOrderProperties()).getChildRef(); nodeService.setProperty(n2, QName.createQName("{namespace}property-1"), "valueone"); nodeService.setProperty(n2, QName.createQName("{namespace}property-2"), "valuetwo"); n3 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}three"), testSuperType, getOrderProperties()).getChildRef(); ObjectOutputStream oos; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(n3); oos.close(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); Object o = ois.readObject(); ois.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } Map<QName, Serializable> testProperties = new HashMap<QName, Serializable>(); testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"), "TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYONE"); testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-unstored-tokenised-atomic"), "TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYUNSTORED"); testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-nonatomic"), "TEXT THAT IS INDEXED STORED AND TOKENISED BUT NOT ATOMICALLY KEYTWO"); testProperties.put(QName.createQName(TEST_NAMESPACE, "int-ista"), Integer.valueOf(1)); testProperties.put(QName.createQName(TEST_NAMESPACE, "long-ista"), Long.valueOf(2)); testProperties.put(QName.createQName(TEST_NAMESPACE, "float-ista"), Float.valueOf(3.4f)); testProperties.put(QName.createQName(TEST_NAMESPACE, "double-ista"), Double.valueOf(5.6)); //testDate = new Date(((new Date().getTime() - 10000))); Calendar c = new GregorianCalendar(); c.setTime(new Date(((new Date().getTime() - 10000)))); //c.add(Calendar.MINUTE, -1); //c.set(Calendar.MINUTE, 0); //c.set(Calendar.MILLISECOND, 999); //c.set(Calendar.SECOND, 1); //c.set(Calendar.MILLISECOND, 0); //c.set(Calendar.SECOND, 0); //c.set(Calendar.MINUTE, 0); //c.set(Calendar.HOUR_OF_DAY, 0); // c.set(Calendar.YEAR, 2000); // c.set(Calendar.MONTH, 12); // c.set(Calendar.DAY_OF_MONTH, 31); // c.set(Calendar.HOUR_OF_DAY, 23); // c.set(Calendar.MINUTE, 59); // c.set(Calendar.SECOND, 59); // c.set(Calendar.MILLISECOND, 999); testDate = c.getTime(); testProperties.put(QName.createQName(TEST_NAMESPACE, "date-ista"), testDate); testProperties.put(QName.createQName(TEST_NAMESPACE, "datetime-ista"), testDate); testProperties.put(QName.createQName(TEST_NAMESPACE, "boolean-ista"), Boolean.valueOf(true)); testProperties.put(QName.createQName(TEST_NAMESPACE, "qname-ista"), QName.createQName("{wibble}wobble")); testProperties.put(QName.createQName(TEST_NAMESPACE, "category-ista"), new NodeRef(storeRef, "CategoryId")); testProperties.put(QName.createQName(TEST_NAMESPACE, "noderef-ista"), n1); testProperties.put(QName.createQName(TEST_NAMESPACE, "path-ista"), nodeService.getPath(n3)); testProperties.put(QName.createQName(TEST_NAMESPACE, "locale-ista"), Locale.UK); testProperties.put(QName.createQName(TEST_NAMESPACE, "period-ista"), new Period("period|12")); testProperties.put(QName.createQName(TEST_NAMESPACE, "null"), null); testProperties.put(QName.createQName(TEST_NAMESPACE, "list"), new ArrayList<Object>()); MLText mlText = new MLText(); mlText.addValue(Locale.ENGLISH, "banana"); mlText.addValue(Locale.FRENCH, "banane"); mlText.addValue(Locale.CHINESE, ""); mlText.addValue(new Locale("nl"), "banaan"); mlText.addValue(Locale.GERMAN, "banane"); mlText.addValue(new Locale("el"), ""); mlText.addValue(Locale.ITALIAN, "banana"); mlText.addValue(new Locale("ja"), "?"); mlText.addValue(new Locale("ko"), ""); mlText.addValue(new Locale("pt"), "banana"); mlText.addValue(new Locale("ru"), ""); mlText.addValue(new Locale("es"), "pltano"); testProperties.put(QName.createQName(TEST_NAMESPACE, "ml"), mlText); // Any multivalued ArrayList<Serializable> anyValues = new ArrayList<Serializable>(); anyValues.add(Integer.valueOf(100)); anyValues.add("anyValueAsString"); anyValues.add(new UnknownDataType()); testProperties.put(QName.createQName(TEST_NAMESPACE, "any-many-ista"), anyValues); // Content multivalued // - note only one the first value is used from the collection // - andit has to go in type d:any as d:content is not allowed to be multivalued ArrayList<Serializable> contentValues = new ArrayList<Serializable>(); contentValues.add(new ContentData(null, "text/plain", 0L, "UTF-16", Locale.UK)); testProperties.put(QName.createQName(TEST_NAMESPACE, "content-many-ista"), contentValues); // MLText multivalued MLText mlText1 = new MLText(); mlText1.addValue(Locale.ENGLISH, "cabbage"); mlText1.addValue(Locale.FRENCH, "chou"); MLText mlText2 = new MLText(); mlText2.addValue(Locale.ENGLISH, "lemur"); mlText2.addValue(new Locale("ru"), ""); ArrayList<Serializable> mlValues = new ArrayList<Serializable>(); mlValues.add(mlText1); mlValues.add(mlText2); testProperties.put(QName.createQName(TEST_NAMESPACE, "mltext-many-ista"), mlValues); // null in multi valued ArrayList<Object> testList = new ArrayList<Object>(); testList.add(null); testProperties.put(QName.createQName(TEST_NAMESPACE, "nullist"), testList); ArrayList<Object> testList2 = new ArrayList<Object>(); testList2.add("woof"); testList2.add(null); n4 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}four"), testType, testProperties).getChildRef(); ContentWriter multiWriter = contentService.getWriter(n4, QName.createQName(TEST_NAMESPACE, "content-many-ista"), true); multiWriter.setEncoding("UTF-16"); multiWriter.setMimetype("text/plain"); multiWriter.putContent("multicontent"); nodeService.getProperties(n1); nodeService.getProperties(n2); nodeService.getProperties(n3); nodeService.getProperties(n4); n5 = nodeService.createNode(n1, ASSOC_TYPE_QNAME, QName.createQName("{namespace}five"), testSuperType, getOrderProperties()).getChildRef(); n6 = nodeService.createNode(n1, ASSOC_TYPE_QNAME, QName.createQName("{namespace}six"), testSuperType, getOrderProperties()).getChildRef(); n7 = nodeService.createNode(n2, ASSOC_TYPE_QNAME, QName.createQName("{namespace}seven"), testSuperType, getOrderProperties()).getChildRef(); n8 = nodeService.createNode(n2, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eight-2"), testSuperType, getOrderProperties()).getChildRef(); n9 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}nine"), testSuperType, getOrderProperties()).getChildRef(); n10 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}ten"), testSuperType, getOrderProperties()).getChildRef(); n11 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eleven"), testSuperType, getOrderProperties()).getChildRef(); n12 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}twelve"), testSuperType, getOrderProperties()).getChildRef(); n13 = nodeService.createNode(n12, ASSOC_TYPE_QNAME, QName.createQName("{namespace}thirteen"), testSuperType, getOrderProperties()).getChildRef(); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); MLText desc1 = new MLText(); desc1.addValue(Locale.ENGLISH, "Alfresco tutorial"); desc1.addValue(Locale.US, "Alfresco tutorial"); Date explicitCreatedDate = new Date(); Thread.sleep(2000); properties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); properties.put(ContentModel.PROP_DESCRIPTION, desc1); properties.put(ContentModel.PROP_CREATED, explicitCreatedDate); //Calendar c = new GregorianCalendar(); //c.setTime(new Date()); //c.set(Calendar.MILLISECOND, 0); //c.set(Calendar.SECOND, 0); //c.set(Calendar.MINUTE, 0); //c.set(Calendar.HOUR_OF_DAY, 0); //testDate = c.getTime(); //properties.put(QName.createQName(TEST_NAMESPACE, "date-ista"), testDate); //properties.put(QName.createQName(TEST_NAMESPACE, "datetime-ista"), testDate); // note: cm:content - hence auditable aspect will be applied with any missing mandatory properties (cm:modified, cm:creator, cm:modifier) n14 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fourteen"), ContentModel.TYPE_CONTENT, properties).getChildRef(); // nodeService.addAspect(n14, DictionaryBootstrap.ASPECT_QNAME_CONTENT, // properties); assertEquals(explicitCreatedDate, nodeService.getProperty(n14, ContentModel.PROP_CREATED)); // note: cm:thumbnail - hence auditable aspect will be applied with mandatory properties (cm:created, cm:modified, cm:creator, cm:modifier) n15 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fifteen"), ContentModel.TYPE_THUMBNAIL, getOrderProperties()).getChildRef(); nodeService.setProperty(n15, ContentModel.PROP_CONTENT, new ContentData(null, "text/richtext", 0L, "UTF-8", Locale.FRENCH)); ContentWriter writer = contentService.getWriter(n14, ContentModel.PROP_CONTENT, true); writer.setEncoding("UTF-8"); // InputStream is = // this.getClass().getClassLoader().getResourceAsStream("test.doc"); // writer.putContent(is); writer.putContent( "The quick brown fox jumped over the lazy dog and ate the Alfresco Tutorial, in pdf format, along with the following stop words; a an and are" + " as at be but by for if in into is it no not of on or such that the their then there these they this to was will with: " + " and random charcters \u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF"); // System.out.println("Size is " + writer.getSize()); writer = contentService.getWriter(n15, ContentModel.PROP_CONTENT, true); writer.setEncoding("UTF-8"); // InputStream is = // this.getClass().getClassLoader().getResourceAsStream("test.doc"); // writer.putContent(is); writer.putContent(" "); nodeService.addChild(rootNodeRef, n8, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}eight-0")); nodeService.addChild(n1, n8, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eight-1")); nodeService.addChild(n2, n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}link")); nodeService.addChild(n1, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n2, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n5, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n6, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n12, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n13, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); documentOrder = new NodeRef[] { rootNodeRef, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n3, n1, n2 }; }