List of usage examples for org.apache.commons.httpclient.util URIUtil decode
public static String decode(String escaped, String charset) throws URIException
From source file:org.elasticsearch.hadoop.util.StringUtils.java
public static String decodePath(String path) { try {//from w ww . ja v a 2 s . c om return URIUtil.decode(path, "UTF-8"); } catch (URIException ex) { throw new EsHadoopIllegalArgumentException("Cannot encode path" + path, ex); } }
From source file:org.lobid.lodmill.PipeLobidOrganisationEnrichment.java
private void startOsmLookupEnrichment() { // activate the geo position bnode enterBnode(this.bnodeIDGeoPos); for (int i = 0; i < 2; i++) { osmUrl[i] = null;//from ww w . j a va 2 s. c om urlOsmLookupSearchParameters[1] = null; } final String firstLiteralOfProperty = getFirstLiteralOfProperty(VcardNs.LOCALITY.uri); if (firstLiteralOfProperty != null) { // OSM Api doesn't like e.g /Marburg%2FLahn/ but accepts /Marburg/. // Having also the postcode we will not encounter ambigous cities try { this.locality = URIUtil.encodeQuery( (URIUtil.decode(firstLiteralOfProperty, "UTF-8").replaceAll("(.*)\\p{Punct}.*", "$1")), "UTF-8"); } catch (URIException e1) { this.locality = firstLiteralOfProperty; e1.printStackTrace(); } } this.postalcode = getFirstLiteralOfProperty(VcardNs.POSTAL_CODE.uri); this.street = getFirstLiteralOfProperty(VcardNs.STREET_ADDRESS.uri); if (!doubles()) { this.countryName = getFirstLiteralOfProperty(VcardNs.COUNTRY_NAME.uri); if (makeOsmApiSearchParameters()) { lookupLocation(); // TODO check whats happening if geo data already in // source file } } if (this.lat != null && this.lon != null) { super.literal(GEO_WGS84_POS_LAT, String.valueOf(this.lat)); super.literal(GEO_WGS84_POS_LONG, String.valueOf(this.lon)); super.literal(RDF_SYNTAX_NS_TYPE, WGS84_POS_SPATIALTHING); } }
From source file:org.lobid.lodmill.PipeLobidOrganisationEnrichment.java
private void sanitizeStreetnameAndRetrieveOsmApiResultAndStoreLatLon(String regex) throws Exception { String tmp = ""; try {//from w w w . ja v a 2 s.c o m tmp = URIUtil.encodeQuery((URIUtil.decode(this.street, "UTF-8").replaceAll(regex, "$1")), "UTF-8"); } catch (URIException e2) { e2.printStackTrace(); } // make new request only if strings differ if (!tmp.equals(this.street)) { this.street = tmp; try { if (makeOsmApiSearchParameters()) { if (!makeUrlAndLookupIfCached()) { this.osmApiLookupResult = getUrlContent(this.osmUrl[1]); parseJsonAndStoreLatLon(); } } } catch (IOException e1) { LOG.error(super.subject + " " + e1.getLocalizedMessage()); } } }
From source file:org.medici.bia.common.search.AdvancedSearchDocument.java
/** * {@inheritDoc}/* w w w. j a v a 2s .c o m*/ */ @Override public void initFromAdvancedSearchCommand(AdvancedSearchCommand command) { //Words if ((command.getWord() != null) && (command.getWord().size() > 0)) { wordsTypes = new ArrayList<WordType>(command.getWord().size()); words = new ArrayList<String>(command.getWord().size()); for (String singleWord : command.getWord()) { //MD: This is for refine search when the URLencoder change the space in "+" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("\"", "%22"); singleWord = singleWord.replace("'", "%27"); //RR: And this is for replacing special characters with unicode values singleWord = URLTransformer.decode(singleWord); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 2) { wordsTypes.add(WordType.valueOf(stringTokenizer.nextToken())); StringBuffer tempString = new StringBuffer( URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); if (StringUtils.countMatches(tempString.toString(), "\"") % 2 != 0) { tempString.setCharAt(tempString.lastIndexOf("\""), ' '); } words.add(tempString.toString()); } else { continue; } } catch (URIException uriException) { logger.debug(uriException); wordsTypes.remove(wordsTypes.size() - 1); } } } else { wordsTypes = new ArrayList<WordType>(0); words = new ArrayList<String>(0); } // Person if ((command.getPerson() != null) && (command.getPerson().size() > 0)) { personId = new ArrayList<Integer>(command.getPerson().size()); person = new ArrayList<String>(command.getPerson().size()); for (String singleWord : command.getPerson()) { //MD: This is for refine search when the URLencoder change the space in "+" singleWord = singleWord.replace("+", "%20"); //RR: And this is for replacing special characters with unicode values singleWord = URLTransformer.decode(singleWord); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { // string format is |text personId.add(new Integer(0)); try { person.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } catch (URIException uriException) { logger.debug(uriException); } } else if (stringTokenizer.countTokens() == 2) { // string format is number|text String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); // Check if field is correct if (NumberUtils.isNumber(singleId)) { personId.add(NumberUtils.createInteger(singleId)); } else { //Empty personId is equal to 0 personId.add(new Integer(0)); } try { person.add(URIUtil.decode(singleText, "UTF-8")); } catch (URIException uriException) { logger.debug(uriException); personId.remove(personId.size() - 1); } } } catch (NumberFormatException nex) { logger.error(nex); } } } else { personId = new ArrayList<Integer>(0); person = new ArrayList<String>(0); } // Place if ((command.getPlace() != null) && (command.getPlace().size() > 0)) { placeId = new ArrayList<Integer>(command.getPlace().size()); place = new ArrayList<String>(command.getPlace().size()); for (String singleWord : command.getPlace()) { //MD: This is for refine search when the URLencoder change the space in "+" singleWord = singleWord.replace("+", "%20"); //RR: And this is for replacing special characters with unicode values singleWord = URLTransformer.decode(singleWord); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { // string format is |text placeId.add(new Integer(0)); place.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else if (stringTokenizer.countTokens() == 2) { // string format is number|text String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); // Check if field is correct if (NumberUtils.isNumber(singleId)) { placeId.add(NumberUtils.createInteger(singleId)); } else { //Empty placeId is equal to 0 placeId.add(new Integer(0)); } place.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException nex) { logger.debug(nex); } catch (URIException uriException) { logger.debug(uriException); placeId.remove(placeId.size() - 1); } } } else { placeId = new ArrayList<Integer>(0); place = new ArrayList<String>(0); } // Sender if ((command.getSender() != null) && (command.getSender().size() > 0)) { senderId = new ArrayList<Integer>(command.getSender().size()); sender = new ArrayList<String>(command.getSender().size()); for (String singleWord : command.getSender()) { StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { // string format is |text senderId.add(new Integer(0)); sender.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else if (stringTokenizer.countTokens() == 2) { // string format is number|text String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); // Check if field is correct if (NumberUtils.isNumber(singleId)) { senderId.add(NumberUtils.createInteger(singleId)); } else { //Empty senderId is equal to 0 senderId.add(new Integer(0)); } sender.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException nex) { logger.debug(nex); } catch (URIException uriException) { logger.debug(uriException); senderId.remove(senderId.size() - 1); } } } else { senderId = new ArrayList<Integer>(0); sender = new ArrayList<String>(0); } // From if ((command.getFrom() != null) && (command.getFrom().size() > 0)) { fromId = new ArrayList<Integer>(command.getFrom().size()); from = new ArrayList<String>(command.getFrom().size()); for (String singleWord : command.getFrom()) { //MD: This is for refine search when the URLencoder change the space in "+" singleWord = singleWord.replace("+", "%20"); //RR: And this is for replacing special characters with unicode values singleWord = URLTransformer.decode(singleWord); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { // string format is |text fromId.add(new Integer(0)); from.add(stringTokenizer.nextToken()); } else if (stringTokenizer.countTokens() == 2) { // string format is number|text String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); // Check if field is correct if (NumberUtils.isNumber(singleId)) { fromId.add(NumberUtils.createInteger(singleId)); } else { //Empty fromId is equal to 0 fromId.add(new Integer(0)); } from.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); fromId.remove(fromId.size() - 1); } } } else { fromId = new ArrayList<Integer>(0); from = new ArrayList<String>(0); } // Recipient if ((command.getRecipient() != null) && (command.getRecipient().size() > 0)) { recipientId = new ArrayList<Integer>(command.getRecipient().size()); recipient = new ArrayList<String>(command.getRecipient().size()); for (String singleWord : command.getRecipient()) { StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { // string format is |text recipientId.add(new Integer(0)); recipient.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else if (stringTokenizer.countTokens() == 2) { // string format is number|text String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); // Check if field is correct if (NumberUtils.isNumber(singleId)) { recipientId.add(NumberUtils.createInteger(singleId)); } else { //Empty recipientId is equal to 0 recipientId.add(new Integer(0)); } recipient.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); recipientId.remove(recipientId.size() - 1); } } } else { recipientId = new ArrayList<Integer>(0); recipient = new ArrayList<String>(0); } // To if ((command.getTo() != null) && (command.getTo().size() > 0)) { toId = new ArrayList<Integer>(command.getTo().size()); to = new ArrayList<String>(command.getTo().size()); for (String singleWord : command.getTo()) { //MD: This is for refine search when the URLencoder change the space in "+" singleWord = singleWord.replace("+", "%20"); //RR: And this is for replacing special characters with unicode values singleWord = URLTransformer.decode(singleWord); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { // string format is |text toId.add(new Integer(0)); to.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else if (stringTokenizer.countTokens() == 2) { // string format is number|text String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); // Check if field is correct if (NumberUtils.isNumber(singleId)) { toId.add(NumberUtils.createInteger(singleId)); } else { //Empty toId is equal to 0 toId.add(new Integer(0)); } to.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); toId.remove(toId.size() - 1); } } } else { toId = new ArrayList<Integer>(0); to = new ArrayList<String>(0); } // ResTo; if ((command.getRefersTo() != null) && (command.getRefersTo().size() > 0)) { refersToId = new ArrayList<Integer>(command.getRefersTo().size()); refersTo = new ArrayList<String>(command.getRefersTo().size()); for (String singleWord : command.getRefersTo()) { StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); // string format is number|text try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { // string format is |text refersToId.add(new Integer(0)); refersTo.add(stringTokenizer.nextToken()); } else if (stringTokenizer.countTokens() == 2) { String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); // Check if field is correct if (NumberUtils.isNumber(singleId)) { refersToId.add(NumberUtils.createInteger(singleId)); } else { //Empty refersToId is equal to 0 refersToId.add(new Integer(0)); } refersTo.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); refersToId.remove(refersToId.size() - 1); } } } else { refersToId = new ArrayList<Integer>(0); refersTo = new ArrayList<String>(0); } // Extract if ((command.getExtract() != null) && (command.getExtract().size() > 0)) { extract = new ArrayList<String>(command.getExtract().size()); for (String singleWord : command.getExtract()) { //MD: This is for refine search when the URLencoder change the space in "+" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("\"", "%22"); singleWord = singleWord.replace("'", "%27"); //RR: And this is for replacing special characters with unicode values singleWord = URLTransformer.decode(singleWord); try { extract.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { extract = new ArrayList<String>(0); } // Synopsis if ((command.getSynopsis() != null) && (command.getSynopsis().size() > 0)) { synopsis = new ArrayList<String>(command.getSynopsis().size()); for (String singleWord : command.getSynopsis()) { singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("\"", "%22"); singleWord = singleWord.replace("'", "%27"); singleWord = URLTransformer.decode(singleWord); try { synopsis.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { synopsis = new ArrayList<String>(0); } // Topics if ((command.getTopic() != null) && (command.getTopic().size() > 0)) { topicsId = new ArrayList<Integer>(command.getTopic().size()); topics = new ArrayList<String>(command.getTopic().size()); topicsPlaceId = new ArrayList<Integer>(command.getTopic().size()); topicsPlace = new ArrayList<String>(command.getTopic().size()); for (String singleWord : command.getTopic()) { singleWord = singleWord.replace("+", "%20"); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { // string format is number String topicId = stringTokenizer.nextToken(); if (NumberUtils.isNumber(topicId)) { topicsId.add(NumberUtils.createInteger(topicId)); } else { //Empty topicsId is equal to 0 topicsId.add(new Integer(0)); } // topics.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else if (stringTokenizer.countTokens() == 2) { // string format is number|text String topicId = stringTokenizer.nextToken(); String topicText = stringTokenizer.nextToken(); // Check if field is correct if (NumberUtils.isNumber(topicId)) { topicsId.add(NumberUtils.createInteger(topicId)); } else { //Empty topicsId is equal to 0 topicsId.add(new Integer(0)); } topics.add(URIUtil.decode(topicText, "UTF-8")); } else if (stringTokenizer.countTokens() == 3) { //string format is number|text|number String singleId = stringTokenizer.nextToken(); String topicText = stringTokenizer.nextToken(); String placeId = stringTokenizer.nextToken(); if (NumberUtils.isNumber(singleId)) { topicsId.add(NumberUtils.createInteger(singleId)); } else { topicsId.add(new Integer(0)); } topics.add(URIUtil.decode(topicText, "UTF-8")); if (NumberUtils.isNumber(placeId)) { topicsPlaceId.add(NumberUtils.createInteger(placeId)); } else { topicsPlaceId.add(new Integer(0)); } } else if (stringTokenizer.countTokens() == 4) { //string format is number|text|number|text String singleId = stringTokenizer.nextToken(); String topicText = stringTokenizer.nextToken(); String placeId = stringTokenizer.nextToken(); String placeText = stringTokenizer.nextToken(); if (NumberUtils.isNumber(singleId)) { topicsId.add(NumberUtils.createInteger(singleId)); } else { topicsId.add(new Integer(0)); } topics.add(URIUtil.decode(topicText, "UTF-8")); if (NumberUtils.isNumber(placeId)) { topicsPlaceId.add(NumberUtils.createInteger(placeId)); } else { topicsPlaceId.add(new Integer(0)); } topicsPlace.add(URIUtil.decode(placeText, "UTF-8")); } } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); topicsId.remove(topicsId.size() - 1); topicsPlaceId.remove(topicsPlaceId.size() - 1); } } } else { topicsId = new ArrayList<Integer>(0); topics = new ArrayList<String>(0); } //Topics Place // Place // if ((command.getTopicPlace() != null) && (command.getTopicPlace().size() >0)) { // topicsPlaceId = new ArrayList<Integer>(command.getTopicPlace().size()); // topicsPlace = new ArrayList<String>(command.getTopicPlace().size()); // // for (String singleWord : command.getTopicPlace()) { // //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" // singleWord = singleWord.replace("+", "%20"); // singleWord = singleWord.replace("%E7", "\u00E7"); // // StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); // try { // if (stringTokenizer.countTokens() == 0) { // continue; // } else if (stringTokenizer.countTokens() == 1) { // // string format is |text // topicsPlaceId.add(new Integer(0)); // topicsPlace.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); // } else if (stringTokenizer.countTokens() == 2) { // // string format is number|text // String singleId = stringTokenizer.nextToken(); // String singleText = stringTokenizer.nextToken(); // // Check if field is correct // if (NumberUtils.isNumber(singleId)) { // topicsPlaceId.add(NumberUtils.createInteger(singleId)); // } else { // //Empty placeId is equal to 0 // topicsPlaceId.add(new Integer(0)); // } // topicsPlace.add(URIUtil.decode(singleText, "UTF-8")); // } // } catch (NumberFormatException numberFormatException) { // logger.debug(numberFormatException); // } catch (URIException uriException) { // logger.debug(uriException); // topicsPlaceId.remove(topicsPlaceId.size()-1); // } // } // } else { // topicsPlaceId = new ArrayList<Integer>(0); // topicsPlace = new ArrayList<String>(0); // } //Date if ((command.getDate() != null) && (command.getDate().size() > 0)) { datesTypes = new ArrayList<DateType>(command.getDate().size()); datesYear = new ArrayList<Integer>(command.getDate().size()); datesMonth = new ArrayList<Integer>(command.getDate().size()); datesDay = new ArrayList<Integer>(command.getDate().size()); datesYearBetween = new ArrayList<Integer>(command.getDate().size()); datesMonthBetween = new ArrayList<Integer>(command.getDate().size()); datesDayBetween = new ArrayList<Integer>(command.getDate().size()); for (String singleWord : command.getDate()) { //e.g. After|1222|01|12|1223|12|12 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesTypes.add(DateType.valueOf(fields[0])); datesYear.add(DateUtils.getDateYearFromString(fields[1])); datesMonth.add(DateUtils.getDateMonthFromString(fields[2])); datesDay.add(DateUtils.getDateDayFromString(fields[3])); datesYearBetween.add(DateUtils.getDateYearFromString(fields[4])); datesMonthBetween.add(DateUtils.getDateMonthFromString(fields[5])); datesDayBetween.add(DateUtils.getDateDayFromString(fields[6])); } } else { datesTypes = new ArrayList<DateType>(0); datesYear = new ArrayList<Integer>(0); datesMonth = new ArrayList<Integer>(0); datesDay = new ArrayList<Integer>(0); datesYearBetween = new ArrayList<Integer>(0); datesMonthBetween = new ArrayList<Integer>(0); datesDayBetween = new ArrayList<Integer>(0); } //Date Created if ((command.getDateCreated() != null) && (command.getDateCreated().size() > 0)) { datesCreatedTypes = new ArrayList<DateType>(command.getDateCreated().size()); datesCreated = new ArrayList<Date>(command.getDateCreated().size()); datesCreatedBetween = new ArrayList<Date>(command.getDateCreated().size()); for (String singleWord : command.getDateCreated()) { //e.g. After|20120112|20120112 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesCreatedTypes.add(DateType.valueOf(fields[0])); datesCreated.add(DateUtils.getDateFromString(fields[1])); datesCreatedBetween.add(DateUtils.getDateFromString(fields[2])); } } else { datesCreatedTypes = new ArrayList<DateType>(0); datesCreated = new ArrayList<Date>(0); datesCreatedBetween = new ArrayList<Date>(0); } //Date lastUpdate if ((command.getDateLastUpdate() != null) && (command.getDateLastUpdate().size() > 0)) { datesLastUpdateTypes = new ArrayList<DateType>(command.getDateLastUpdate().size()); datesLastUpdate = new ArrayList<Date>(command.getDateLastUpdate().size()); datesLastUpdateBetween = new ArrayList<Date>(command.getDateLastUpdate().size()); for (String singleWord : command.getDateLastUpdate()) { //e.g. After|20120112|20120112 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesLastUpdateTypes.add(DateType.valueOf(fields[0])); datesLastUpdate.add(DateUtils.getDateFromString(fields[1])); datesLastUpdateBetween.add(DateUtils.getDateFromString(fields[2])); } } else { datesLastUpdateTypes = new ArrayList<DateType>(0); datesLastUpdate = new ArrayList<Date>(0); datesLastUpdateBetween = new ArrayList<Date>(0); } //Volume if ((command.getVolume() != null) && (command.getVolume().size() > 0)) { volumesTypes = new ArrayList<VolumeType>(command.getVolume().size()); volumes = new ArrayList<String>(command.getVolume().size()); volumesBetween = new ArrayList<String>(command.getVolume().size()); for (String singleWord : command.getVolume()) { StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); if ((stringTokenizer.countTokens() == 0) || (stringTokenizer.countTokens() == 1)) { continue; } else if (stringTokenizer.countTokens() == 2) { // string format is Exactly|12 volumesTypes.add(VolumeType.valueOf(stringTokenizer.nextToken())); volumes.add(stringTokenizer.nextToken()); volumesBetween.add("0"); } else if (stringTokenizer.countTokens() == 3) { // string format is Exactly|12|16 volumesTypes.add(VolumeType.valueOf(stringTokenizer.nextToken())); volumes.add(stringTokenizer.nextToken()); volumesBetween.add(stringTokenizer.nextToken()); } } } else { volumesTypes = new ArrayList<VolumeType>(0); volumes = new ArrayList<String>(0); volumesBetween = new ArrayList<String>(0); } // Insert if ((command.getInsert() != null && command.getInsert().size() > 0)) { insertNums = new ArrayList<String>(command.getInsert().size()); for (String insert : command.getInsert()) { insertNums.add(insert); } } else { insertNums = new ArrayList<String>(0); } //Folio if ((command.getFolio() != null) && (command.getFolio().size() > 0)) { foliosTypes = new ArrayList<AdvancedSearchAbstract.FolioType>(command.getFolio().size()); folios = new ArrayList<String>(command.getFolio().size()); foliosBetween = new ArrayList<String>(command.getFolio().size()); for (String singleWord : command.getFolio()) { StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); if ((stringTokenizer.countTokens() == 0) || (stringTokenizer.countTokens() == 1)) { continue; } else if (stringTokenizer.countTokens() == 2) { foliosTypes.add(FolioType.valueOf(stringTokenizer.nextToken())); folios.add(stringTokenizer.nextToken()); foliosBetween.add("0"); } else if (stringTokenizer.countTokens() == 3) { foliosTypes.add(FolioType.valueOf(stringTokenizer.nextToken())); folios.add(stringTokenizer.nextToken()); foliosBetween.add(stringTokenizer.nextToken()); } } } else { foliosTypes = new ArrayList<AdvancedSearchAbstract.FolioType>(0); folios = new ArrayList<String>(0); foliosBetween = new ArrayList<String>(0); } //FolioMod if (command.getFolioMod() != null && command.getFolioMod().size() > 0) { folioMods = new ArrayList<String>(command.getFolioMod().size()); folioMods.addAll(command.getFolioMod()); } else { folioMods = new ArrayList<String>(0); } //EntryId if ((command.getDocId() != null) && (command.getDocId().size() > 0)) { docIds = new ArrayList<String>(command.getDocId().size()); for (String singleWord : command.getDocId()) { try { docIds.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { docIds = new ArrayList<String>(0); } //LogicalDelete if (command.getLogicalDelete() != null) { if (command.getLogicalDelete().equals("true")) { logicalDelete = Boolean.TRUE; } else { logicalDelete = Boolean.FALSE; } } //Users if (command.getUser() != null) { userActionTypes = new ArrayList<UserActionType>(command.getUser().size()); users = new ArrayList<String>(command.getUser().size()); for (String singleUser : command.getUser()) { //MD: This is for refine search when the URLencoder change the space in "+" singleUser = singleUser.replace("+", "%20"); singleUser = singleUser.replace("\"", "%22"); singleUser = singleUser.replace("'", "%27"); //RR: And this is for replacing special characters with unicode values singleUser = URLTransformer.decode(singleUser); StringTokenizer stringTokenizer = new StringTokenizer(singleUser, "|"); try { if (stringTokenizer.countTokens() == 2) { userActionTypes.add(UserActionType.valueOf(stringTokenizer.nextToken())); StringBuffer tempString = new StringBuffer( URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); if (StringUtils.countMatches(tempString.toString(), "\"") % 2 != 0) { tempString.setCharAt(tempString.lastIndexOf("\""), ' '); } users.add(tempString.toString()); } else { continue; } } catch (URIException uriException) { logger.debug(uriException); wordsTypes.remove(wordsTypes.size() - 1); } } } else { userActionTypes = new ArrayList<UserActionType>(0); users = new ArrayList<String>(0); } }
From source file:org.medici.bia.common.search.AdvancedSearchPeople.java
/** * {@inheritDoc} /*from ww w . ja v a2 s.c om*/ */ @Override public void initFromAdvancedSearchCommand(AdvancedSearchCommand command) { //Names if ((command.getNameParts() != null) && (command.getNameParts().size() > 0)) { namesTypes = new ArrayList<NameType>(command.getNameParts().size()); names = new ArrayList<String>(command.getNameParts().size()); for (String singleWord : command.getNameParts()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 2) { namesTypes.add(NameType.valueOf(stringTokenizer.nextToken().replace(" ", ""))); names.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else { continue; } } catch (URIException uriException) { logger.debug(uriException); namesTypes.remove(namesTypes.size() - 1); } } } else { namesTypes = new ArrayList<AdvancedSearchAbstract.NameType>(0); names = new ArrayList<String>(0); } //Exact Name if ((command.getPerson() != null) && (command.getPerson().size() > 0)) { personId = new ArrayList<Integer>(command.getPerson().size()); exactName = new ArrayList<String>(command.getPerson().size()); for (String singleWord : command.getPerson()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { personId.add(new Integer(0)); exactName.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else if (stringTokenizer.countTokens() == 2) { String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); if (NumberUtils.isNumber(singleId)) { personId.add(NumberUtils.createInteger(singleId)); } else { personId.add(new Integer(0)); } exactName.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); personId.remove(personId.size() - 1); } } } else { exactName = new ArrayList<String>(0); personId = new ArrayList<Integer>(0); } //Words if ((command.getWord() != null) && (command.getWord().size() > 0)) { //wordsTypes = new ArrayList<WordType>(command.getWord().size()); words = new ArrayList<String>(command.getWord().size()); for (String singleWord : command.getWord()) { //StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { //if (stringTokenizer.countTokens() == 2) { //wordsTypes.add(WordType.valueOf(stringTokenizer.nextToken())); //words.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); words.add(URIUtil.decode(singleWord, "UTF-8")); //} else { // continue; //} } catch (URIException uriException) { logger.debug(uriException); //wordsTypes.remove(wordsTypes.size()-1); words.remove(words.size() - 1); } } } else { wordsTypes = new ArrayList<WordType>(0); words = new ArrayList<String>(0); } //Date if ((command.getDate() != null) && (command.getDate().size() > 0)) { datesTypes = new ArrayList<String>(command.getDate().size()); datesYear = new ArrayList<Integer>(command.getDate().size()); datesMonth = new ArrayList<Integer>(command.getDate().size()); datesDay = new ArrayList<Integer>(command.getDate().size()); datesYearBetween = new ArrayList<Integer>(command.getDate().size()); datesMonthBetween = new ArrayList<Integer>(command.getDate().size()); datesDayBetween = new ArrayList<Integer>(command.getDate().size()); for (String singleWord : command.getDate()) { //e.g. After|1222|01|12|1223|12|12 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); try { datesTypes.add(URIUtil.decode(fields[0], "UTF-8")); } catch (URIException uriException) { logger.debug(uriException); } datesYear.add(DateUtils.getDateYearFromString(fields[1])); datesMonth.add(DateUtils.getDateMonthFromString(fields[2])); datesDay.add(DateUtils.getDateDayFromString(fields[3])); datesYearBetween.add(DateUtils.getDateYearFromString(fields[4])); datesMonthBetween.add(DateUtils.getDateMonthFromString(fields[5])); datesDayBetween.add(DateUtils.getDateDayFromString(fields[6])); } } else { datesTypes = new ArrayList<String>(0); datesYear = new ArrayList<Integer>(0); datesMonth = new ArrayList<Integer>(0); datesDay = new ArrayList<Integer>(0); datesYearBetween = new ArrayList<Integer>(0); datesMonthBetween = new ArrayList<Integer>(0); datesDayBetween = new ArrayList<Integer>(0); } //Date lastUpdate if ((command.getDateLastUpdate() != null) && (command.getDateLastUpdate().size() > 0)) { datesLastUpdateTypes = new ArrayList<DateType>(command.getDateLastUpdate().size()); datesLastUpdate = new ArrayList<Date>(command.getDateLastUpdate().size()); datesLastUpdateBetween = new ArrayList<Date>(command.getDateLastUpdate().size()); for (String singleWord : command.getDateLastUpdate()) { //e.g. After|20120112|20120112 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesLastUpdateTypes.add(DateType.valueOf(fields[0])); datesLastUpdate.add(DateUtils.getDateFromString(fields[1])); datesLastUpdateBetween.add(DateUtils.getDateFromString(fields[2])); } } else { datesLastUpdateTypes = new ArrayList<DateType>(0); datesLastUpdate = new ArrayList<Date>(0); datesLastUpdateBetween = new ArrayList<Date>(0); } //Date Created if ((command.getDateCreated() != null) && (command.getDateCreated().size() > 0)) { datesCreatedTypes = new ArrayList<DateType>(command.getDateCreated().size()); datesCreated = new ArrayList<Date>(command.getDateCreated().size()); datesCreatedBetween = new ArrayList<Date>(command.getDateCreated().size()); for (String singleWord : command.getDateCreated()) { //e.g. After|20120112|20120112 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesCreatedTypes.add(DateType.valueOf(fields[0])); datesCreated.add(DateUtils.getDateFromString(fields[1])); datesCreatedBetween.add(DateUtils.getDateFromString(fields[2])); } } else { datesCreatedTypes = new ArrayList<DateType>(0); datesCreated = new ArrayList<Date>(0); datesCreatedBetween = new ArrayList<Date>(0); } //Role Categories if ((command.getRoleCategory() != null) && (command.getRoleCategory().size() > 0)) { roleCategories = new ArrayList<String>(command.getRoleCategory().size()); for (String singleWord : command.getRoleCategory()) { try { roleCategories.add(URIUtil.decode(singleWord, "UTF-8")); } catch (URIException uriException) { logger.debug(uriException); roleCategories.remove(roleCategories.size() - 1); } } } else { roleCategories = new ArrayList<String>(0); } //OccupationsWords if ((command.getOccupationWord() != null) && (command.getOccupationWord().size() > 0)) { titleOccWord = new ArrayList<String>(command.getOccupationWord().size()); for (String singleWord : command.getOccupationWord()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); try { titleOccWord.add(URIUtil.decode(singleWord, "UTF-8")); } catch (URIException uriException) { logger.debug(uriException); } } } else { titleOccWord = new ArrayList<String>(0); } //Occupations if ((command.getOccupation() != null) && (command.getOccupation().size() > 0)) { titlesOccId = new ArrayList<Integer>(command.getOccupation().size()); titlesOcc = new ArrayList<String>(command.getOccupation().size()); for (String singleWord : command.getOccupation()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { titlesOccId.add(new Integer(0)); titlesOcc.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else if (stringTokenizer.countTokens() == 2) { String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); if (NumberUtils.isNumber(singleId)) { titlesOccId.add(NumberUtils.createInteger(singleId)); } else { titlesOccId.add(new Integer(0)); } titlesOcc.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); titlesOccId.remove(titlesOccId.size() - 1); } } } else { titlesOcc = new ArrayList<String>(0); titlesOccId = new ArrayList<Integer>(0); } //Gender if ((command.getGender() != null) && (command.getGender().size() > 0)) { gender = new ArrayList<AdvancedSearchAbstract.Gender>(command.getGender().size()); for (String singleWord : command.getGender()) { try { gender.add(Gender.valueOf(URIUtil.decode(singleWord, "UTF-8"))); } catch (URIException uriException) { logger.debug(uriException); } } } else { gender = new ArrayList<AdvancedSearchAbstract.Gender>(0); } //Places if ((command.getPlace() != null) && (command.getPlace().size() > 0)) { placeId = new ArrayList<Integer>(command.getPlace().size()); place = new ArrayList<String>(command.getPlace().size()); placeType = new ArrayList<String>(command.getPlace().size()); for (String singleWord : command.getPlace()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { placeId.add(new Integer(0)); place.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else if (stringTokenizer.countTokens() == 2) { String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); if (NumberUtils.isNumber(singleId)) { placeId.add(NumberUtils.createInteger(singleId)); } else { placeId.add(new Integer(0)); } place.add(URIUtil.decode(singleText, "UTF-8")); } else if (stringTokenizer.countTokens() == 3) { placeType.add(stringTokenizer.nextToken()); String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); if (NumberUtils.isNumber(singleId)) { placeId.add(NumberUtils.createInteger(singleId)); } else { placeId.add(new Integer(0)); } place.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); placeId.remove(placeId.size() - 1); } } } else { placeId = new ArrayList<Integer>(0); place = new ArrayList<String>(0); placeType = new ArrayList<String>(0); } //Research Notes if ((command.getResearchNotes() != null) && (command.getResearchNotes().size() > 0)) { researchNotes = new ArrayList<String>(command.getResearchNotes().size()); for (String singleWord : command.getResearchNotes()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); try { researchNotes.add(URIUtil.decode(singleWord, "UTF-8")); } catch (URIException uriException) { logger.debug(uriException); researchNotes.remove(researchNotes.size() - 1); } } } else { researchNotes = new ArrayList<String>(0); } //PersonId if ((command.getPersonId() != null) && (command.getPersonId().size() > 0)) { peopleId = new ArrayList<String>(command.getPersonId().size()); for (String singleWord : command.getPersonId()) { try { peopleId.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { peopleId = new ArrayList<String>(0); } //Logical Delete if (command.getLogicalDelete() != null) { if (command.getLogicalDelete().equals("true")) { logicalDelete = Boolean.TRUE; } else { logicalDelete = Boolean.FALSE; } } }
From source file:org.medici.bia.common.search.AdvancedSearchPlace.java
/** * {@inheritDoc}//w w w . j a v a 2s. c om */ @Override public void initFromAdvancedSearchCommand(AdvancedSearchCommand command) { // Place Name if ((command.getPlaceName() != null) && (command.getPlaceName().size() > 0)) { placesName = new ArrayList<String>(command.getPlaceName().size()); for (String singleWord : command.getPlaceName()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); try { placesName.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { placesName = new ArrayList<String>(0); } //Exact Place Name if ((command.getPlace() != null) && (command.getPlace().size() > 0)) { placeId = new ArrayList<Integer>(command.getPlace().size()); exactPlaceName = new ArrayList<String>(command.getPlace().size()); for (String singleWord : command.getPlace()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 0) { continue; } else if (stringTokenizer.countTokens() == 1) { placeId.add(new Integer(0)); exactPlaceName.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else if (stringTokenizer.countTokens() == 2) { String singleId = stringTokenizer.nextToken(); String singleText = stringTokenizer.nextToken(); if (NumberUtils.isNumber(singleId)) { placeId.add(NumberUtils.createInteger(singleId)); } else { placeId.add(new Integer(0)); } exactPlaceName.add(URIUtil.decode(singleText, "UTF-8")); } } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); placeId.remove(placeId.size() - 1); } } } else { exactPlaceName = new ArrayList<String>(0); placeId = new ArrayList<Integer>(0); } //Place Type if ((command.getPlaceType() != null) && (command.getPlaceType().size() > 0)) { placeType = new ArrayList<String>(command.getPlaceType().size()); for (String singleWord : command.getPlaceType()) { try { placeType.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { placeType = new ArrayList<String>(0); } //Linked To People if ((command.getLinkedToPeople() != null) && (command.getLinkedToPeople().size() > 0)) { linkedToPeople = new ArrayList<String>(command.getLinkedToPeople().size()); for (String singleWord : command.getLinkedToPeople()) { try { linkedToPeople.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { linkedToPeople = new ArrayList<String>(0); } //Date lastUpdate if ((command.getDateLastUpdate() != null) && (command.getDateLastUpdate().size() > 0)) { datesLastUpdateTypes = new ArrayList<DateType>(command.getDateLastUpdate().size()); datesLastUpdate = new ArrayList<Date>(command.getDateLastUpdate().size()); datesLastUpdateBetween = new ArrayList<Date>(command.getDateLastUpdate().size()); for (String singleWord : command.getDateLastUpdate()) { //e.g. After|20120112|20120112 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesLastUpdateTypes.add(DateType.valueOf(fields[0])); datesLastUpdate.add(DateUtils.getDateFromString(fields[1])); datesLastUpdateBetween.add(DateUtils.getDateFromString(fields[2])); } } else { datesLastUpdateTypes = new ArrayList<DateType>(0); datesLastUpdate = new ArrayList<Date>(0); datesLastUpdateBetween = new ArrayList<Date>(0); } //Date Created if ((command.getDateCreated() != null) && (command.getDateCreated().size() > 0)) { datesCreatedTypes = new ArrayList<DateType>(command.getDateCreated().size()); datesCreated = new ArrayList<Date>(command.getDateCreated().size()); datesCreatedBetween = new ArrayList<Date>(command.getDateCreated().size()); for (String singleWord : command.getDateCreated()) { //e.g. After|20120112|20120112 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesCreatedTypes.add(DateType.valueOf(fields[0])); datesCreated.add(DateUtils.getDateFromString(fields[1])); datesCreatedBetween.add(DateUtils.getDateFromString(fields[2])); } } else { datesCreatedTypes = new ArrayList<DateType>(0); datesCreated = new ArrayList<Date>(0); datesCreatedBetween = new ArrayList<Date>(0); } //PlaceAllId if ((command.getPlaceId() != null) && (command.getPlaceId().size() > 0)) { placesId = new ArrayList<String>(command.getPlaceId().size()); for (String singleWord : command.getPlaceId()) { try { placesId.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { placesId = new ArrayList<String>(0); } //LogicalDelete if (command.getLogicalDelete() != null) { if (command.getLogicalDelete().equals("true")) { logicalDelete = Boolean.TRUE; } else { logicalDelete = Boolean.FALSE; } } }
From source file:org.medici.bia.common.search.AdvancedSearchVolume.java
/** * {@inheritDoc}/*w w w .java 2 s . c om*/ */ @Override public void initFromAdvancedSearchCommand(AdvancedSearchCommand command) { //Words if ((command.getWord() != null) && (command.getWord().size() > 0)) { wordsTypes = new ArrayList<WordType>(command.getWord().size()); words = new ArrayList<String>(command.getWord().size()); for (String singleWord : command.getWord()) { StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); try { if (stringTokenizer.countTokens() == 2) { wordsTypes.add(WordType.valueOf(stringTokenizer.nextToken())); words.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8")); } else { continue; } } catch (URIException uriException) { logger.debug(uriException); wordsTypes.remove(wordsTypes.size() - 1); } } } else { wordsTypes = new ArrayList<WordType>(0); words = new ArrayList<String>(0); } //Date if ((command.getDate() != null) && (command.getDate().size() > 0)) { datesTypes = new ArrayList<DateType>(command.getDate().size()); datesYear = new ArrayList<Integer>(command.getDate().size()); datesMonth = new ArrayList<Integer>(command.getDate().size()); datesDay = new ArrayList<Integer>(command.getDate().size()); datesYearBetween = new ArrayList<Integer>(command.getDate().size()); datesMonthBetween = new ArrayList<Integer>(command.getDate().size()); datesDayBetween = new ArrayList<Integer>(command.getDate().size()); for (String singleWord : command.getDate()) { //e.g. After|1222|01|12|1223|12|12 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesTypes.add(DateType.valueOf(fields[0])); datesYear.add(DateUtils.getDateYearFromString(fields[1])); datesMonth.add(DateUtils.getDateMonthFromString(fields[2])); datesDay.add(DateUtils.getDateDayFromString(fields[3])); datesYearBetween.add(DateUtils.getDateYearFromString(fields[4])); datesMonthBetween.add(DateUtils.getDateMonthFromString(fields[5])); datesDayBetween.add(DateUtils.getDateDayFromString(fields[6])); } } else { datesTypes = new ArrayList<DateType>(0); datesYear = new ArrayList<Integer>(0); datesMonth = new ArrayList<Integer>(0); datesDay = new ArrayList<Integer>(0); datesYearBetween = new ArrayList<Integer>(0); datesMonthBetween = new ArrayList<Integer>(0); datesDayBetween = new ArrayList<Integer>(0); } //Date lastUpdate if ((command.getDateLastUpdate() != null) && (command.getDateLastUpdate().size() > 0)) { datesLastUpdateTypes = new ArrayList<DateType>(command.getDateLastUpdate().size()); datesLastUpdate = new ArrayList<Date>(command.getDateLastUpdate().size()); datesLastUpdateBetween = new ArrayList<Date>(command.getDateLastUpdate().size()); for (String singleWord : command.getDateLastUpdate()) { //e.g. After|20120112|20120112 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesLastUpdateTypes.add(DateType.valueOf(fields[0])); datesLastUpdate.add(DateUtils.getDateFromString(fields[1])); datesLastUpdateBetween.add(DateUtils.getDateFromString(fields[2])); } } else { datesLastUpdateTypes = new ArrayList<DateType>(0); datesLastUpdate = new ArrayList<Date>(0); datesLastUpdateBetween = new ArrayList<Date>(0); } //Date Created if ((command.getDateCreated() != null) && (command.getDateCreated().size() > 0)) { datesCreatedTypes = new ArrayList<DateType>(command.getDateCreated().size()); datesCreated = new ArrayList<Date>(command.getDateCreated().size()); datesCreatedBetween = new ArrayList<Date>(command.getDateCreated().size()); for (String singleWord : command.getDateCreated()) { //e.g. After|20120112|20120112 String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|"); datesCreatedTypes.add(DateType.valueOf(fields[0])); datesCreated.add(DateUtils.getDateFromString(fields[1])); datesCreatedBetween.add(DateUtils.getDateFromString(fields[2])); } } else { datesCreatedTypes = new ArrayList<DateType>(0); datesCreated = new ArrayList<Date>(0); datesCreatedBetween = new ArrayList<Date>(0); } //Volume if ((command.getVolume() != null) && (command.getVolume().size() > 0)) { volumesTypes = new ArrayList<VolumeType>(command.getVolume().size()); volumes = new ArrayList<String>(command.getVolume().size()); volumesBetween = new ArrayList<String>(command.getVolume().size()); for (String singleWord : command.getVolume()) { StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|"); if ((stringTokenizer.countTokens() == 0) || (stringTokenizer.countTokens() == 1)) { continue; } else if (stringTokenizer.countTokens() == 2) { // string format is Exactly|12 volumesTypes.add(VolumeType.valueOf(stringTokenizer.nextToken())); volumes.add(stringTokenizer.nextToken()); volumesBetween.add("0"); } else if (stringTokenizer.countTokens() == 3) { // string format is Exactly|12|16 volumesTypes.add(VolumeType.valueOf(stringTokenizer.nextToken())); volumes.add(stringTokenizer.nextToken()); volumesBetween.add(stringTokenizer.nextToken()); } } } else { volumesTypes = new ArrayList<VolumeType>(0); volumes = new ArrayList<String>(0); volumesBetween = new ArrayList<String>(0); } //Insert if ((command.getInsert() != null && command.getInsert().size() > 0)) { insertNums = new ArrayList<String>(command.getInsert().size()); for (String insert : command.getInsert()) { insertNums.add(insert); } } else { insertNums = new ArrayList<String>(0); } //Digitized if (command.getDigitized() != null) { if (command.getDigitized().equals("Yes")) { digitized = true; } else { digitized = false; } } //Languages if (command.getLanguages() != null && command.getLanguages().size() > 0) { languages = new ArrayList<String>(command.getLanguages().size()); languages.addAll(command.getLanguages()); } else { languages = new ArrayList<String>(0); } //Other Languages if (command.getOtherLang() != null && command.getOtherLang().size() > 0) { otherLang = new ArrayList<String>(command.getOtherLang().size()); otherLang.addAll(command.getOtherLang()); } else { otherLang = new ArrayList<String>(0); } //Cypher if (command.getCipher() != null) { cipher = new String(command.getCipher()); } else { cipher = new String(); } //Index if (command.getIndex() != null) { index = new String(command.getIndex()); } else { index = new String(); } //From if (command.getFromVolume() != null && command.getFromVolume().size() > 0) { fromVolume = new ArrayList<String>(command.getFromVolume().size()); for (String singleWord : command.getFromVolume()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); singleWord = singleWord.replace("\"", "%22"); singleWord = singleWord.replace("'", "%27"); try { fromVolume.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { fromVolume = new ArrayList<String>(0); } //To if (command.getToVolume() != null && command.getToVolume().size() > 0) { toVolume = new ArrayList<String>(command.getToVolume().size()); for (String singleWord : command.getToVolume()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); singleWord = singleWord.replace("\"", "%22"); singleWord = singleWord.replace("'", "%27"); try { toVolume.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { toVolume = new ArrayList<String>(0); } //Context if (command.getContext() != null && command.getContext().size() > 0) { context = new ArrayList<String>(command.getContext().size()); for (String singleWord : command.getContext()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); singleWord = singleWord.replace("\"", "%22"); singleWord = singleWord.replace("'", "%27"); try { context.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { context = new ArrayList<String>(0); } //Inventario Sommario if (command.getInventario() != null && command.getInventario().size() > 0) { inventario = new ArrayList<String>(command.getInventario().size()); for (String singleWord : command.getInventario()) { //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7" singleWord = singleWord.replace("+", "%20"); singleWord = singleWord.replace("%E7", "\u00E7"); singleWord = singleWord.replace("\"", "%22"); singleWord = singleWord.replace("'", "%27"); try { inventario.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { inventario = new ArrayList<String>(0); } //SummaryId if ((command.getVolumeId() != null) && (command.getVolumeId().size() > 0)) { volumesId = new ArrayList<String>(command.getVolumeId().size()); for (String singleWord : command.getVolumeId()) { try { volumesId.add(URIUtil.decode(singleWord, "UTF-8")); } catch (NumberFormatException numberFormatException) { logger.debug(numberFormatException); } catch (URIException uriException) { logger.debug(uriException); } } } else { volumesId = new ArrayList<String>(0); } //LogicalDelete if (command.getLogicalDelete() != null) { if (command.getLogicalDelete().equals("true")) { logicalDelete = Boolean.TRUE; } else { logicalDelete = Boolean.FALSE; } } }
From source file:org.medici.bia.controller.admin.AjaxController.java
/** * /* w w w .j a v a2 s . com*/ * @param account * @return */ @RequestMapping(value = "/admin/ApproveNewUser.json", method = RequestMethod.POST) public ModelAndView searchUser(@RequestParam(value = "account") String account) { Map<String, Object> model = new HashMap<String, Object>(0); try { account = URIUtil.decode(account, "UTF-8"); } catch (URIException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (account != null && account != "") { User user = new User(account); user.setApproved(Boolean.TRUE); try { user = getAdminService().approveNewUser(user); model.put("operation", "OK"); return new ModelAndView("responseOK", model); } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); model.put("operation", "KO"); return new ModelAndView("responseKO", model); } } model.put("operation", "KO"); return new ModelAndView("responseKO", model); }
From source file:org.medici.bia.controller.admin.AjaxController.java
/** * //from www. j a v a 2s . c om * @param account * @return */ @RequestMapping(value = "/admin/UnlockUser.json", method = RequestMethod.POST) public ModelAndView unlockUser(@RequestParam(value = "account") String account) { Map<String, Object> model = new HashMap<String, Object>(0); try { account = URIUtil.decode(account, "UTF-8"); } catch (URIException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (account != null && account != "") { User user = new User(account); user.setLocked(false); try { user = getAdminService().unlockUser(user); model.put("operation", "OK"); return new ModelAndView("responseOK", model); } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); model.put("operation", "KO"); return new ModelAndView("responseKO", model); } } model.put("operation", "KO"); return new ModelAndView("responseKO", model); }
From source file:org.medici.bia.controller.community.SimpleSearchForumPostController.java
/** * This controller act as a dispatcher for result view. * /*from ww w .j av a 2s. c o m*/ * @param command * @param result * @return */ @RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }) public ModelAndView processSubmit(@ModelAttribute("command") SimpleSearchForumPostCommand command) { Map<String, Object> model = new HashMap<String, Object>(0); try { command.setSearchForumAllText(URIUtil.decode(command.getSearchForumAllText(), "UTF-8")); } catch (URIException uriException) { logger.debug(uriException); } model.put("yourSearch", command.getSearchForumAllText()); String[] toHighlight = StringUtils.split(command.getSearchForumAllText(), " "); model.put("toHighlight", toHighlight); if (command.getSearchForumAllText().contains("\"")) { command.setSearchForumAllText(command.getSearchForumAllText().replace("\"", "\\\"")); } // This number is used to generate an unique id for new search UUID uuid = UUID.randomUUID(); command.setSearchUUID(uuid.toString()); model.put("searchUUID", uuid.toString()); PaginationFilter paginationFilter = new PaginationFilter(); if (command.getResultsForPage() != null) { paginationFilter.setElementsForPage(command.getResultsForPage()); } else { paginationFilter.setElementsForPage(new Integer(10)); } if (command.getResultPageNumber() != null) { paginationFilter.setThisPage(command.getResultPageNumber()); } else { paginationFilter.setThisPage(new Integer(1)); } if (command.getResultPageTotal() != null) { paginationFilter.setPageTotal(command.getResultPageTotal()); } else { paginationFilter.setPageTotal(null); } if (command.getSortResults().equals("POST_TIME")) { paginationFilter.addSortingCriteria("dateCreated", command.getOrder()); } else if (command.getSortResults().equals("AUTHOR")) { paginationFilter.addSortingCriteria("author", command.getOrder()); } else if (command.getSortResults().equals("FORUM")) { paginationFilter.addSortingCriteria("forum.title", command.getOrder()); } else if (command.getSortResults().equals("TOPIC_TITLE")) { paginationFilter.addSortingCriteria("topic.subject", command.getOrder()); } else if (command.getSortResults().equals("POST_SUBJECT")) { paginationFilter.addSortingCriteria("subject", command.getOrder()); } Page page = new Page(paginationFilter); try { if (command.getTopicId() == null) { page = getCommunityService().searchForumPosts( new SimpleSearchForumPost(command.getSearchForumAllText()), paginationFilter); } else { page = getCommunityService().searchForumPosts( new SimpleSearchForumPost(command.getSearchForumAllText(), command.getTopicId()), paginationFilter); } } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); page = new Page(paginationFilter); } model.put("simpleSearchResultPage", page); return new ModelAndView("community/SearchResultForumPost", model); }