List of usage examples for java.util Locale GERMANY
Locale GERMANY
To view the source code for java.util Locale GERMANY.
Click Source Link
From source file:org.openestate.io.is24_csv.Is24CsvRecord.java
public void setKontaktLand(String value) { this.set(FIELD_KONTAKT_LAND, StringUtils.defaultIfBlank(Is24CsvFormat.getCountryCode(value), Locale.GERMANY.getISO3Country())); }
From source file:org.openestate.io.is24_csv.Is24CsvRecord.java
public void setObjektLand(String value) { this.set(FIELD_OBJEKT_LAND, StringUtils.defaultIfBlank(Is24CsvFormat.getCountryCode(value), Locale.GERMANY.getISO3Country())); }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
private void dto2Components() { try {// ww w . j a v a2 s.com JCRDocDto dataJCR = DelegateFactory.getInstance().getJCRDocDelegate().getData(jcrDocDto); if (dataJCR != null) { jcrDocDto = dataJCR; } } catch (Throwable t) { } if (jcrDocDto.getbData() != null) { if (file == null) { try { file = File.createTempFile(jcrDocDto.getsFilename(), jcrDocDto.getsMIME()); FileOutputStream fosFileGetter = new FileOutputStream(file); fosFileGetter.write(jcrDocDto.getbData()); fosFileGetter.close(); } catch (Exception e) { } } } PersonalDto anlegerDto = null; try { anlegerDto = DelegateFactory.getInstance().getPersonalDelegate() .personalFindByPrimaryKey(new Integer((int) jcrDocDto.getlAnleger())); } catch (Throwable e1) { } if (anlegerDto == null) { wtfAnleger.setText(""); } else { wtfAnleger.setText(anlegerDto.getCKurzzeichen()); } try { if (jcrDocDto.getlPartner() != null) { partnerDto = DelegateFactory.getInstance().getPartnerDelegate() .partnerFindByPrimaryKey(jcrDocDto.getlPartner().intValue()); } } catch (ExceptionLP e) { // e.printStackTrace(); } if (partnerDto != null) { wtfPartner.setText(partnerDto.formatFixTitelName1Name2()); } else { wtfPartner.setText(""); } DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.GERMANY); wdfZeitpunkt.setText(df.format(new Timestamp(jcrDocDto.getlZeitpunkt()))); wtfBelegnummer.setText(jcrDocDto.getsBelegnummer()); wtfSchlagworte.setText(jcrDocDto.getsSchlagworte()); wtfName.setText(jcrDocDto.getsName()); wtfFilename.setText(jcrDocDto.getsFilename()); wtfTable.setText( (jcrDocDto.getsTable() == null || jcrDocDto.getsTable().isEmpty()) ? " " : jcrDocDto.getsTable()); wtfRow.setText(jcrDocDto.getsRow()); wtfMIME.setText(jcrDocDto.getsMIME()); wcbVersteckt.setSelected(jcrDocDto.getbVersteckt()); if (jcrDocDto.getlSicherheitsstufe() == JCRDocFac.SECURITY_ARCHIV) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_ARCHIV); } wcbSicherheitsstufe.setSelectedItem(jcrDocDto.getlSicherheitsstufe()); if (JCRDocFac.DEFAULT_ARCHIV_BELEGART.equals(jcrDocDto.getsBelegart())) { wcbBelegart.addItem(JCRDocFac.DEFAULT_ARCHIV_BELEGART); } wcbBelegart.setSelectedItem(jcrDocDto.getsBelegart()); wcbGruppierung.setSelectedItem(jcrDocDto.getsGruppierung()); try { if (".JPG".equals(jcrDocDto.getsMIME().toUpperCase()) || ".JPEG".equals(jcrDocDto.getsMIME().toUpperCase())) { wmcMedia.setMimeType(MediaFac.DATENFORMAT_MIMETYPE_IMAGE_JPEG); wmcMedia.setOMedia(Helper.getBytesFromFile(file)); } else if (".JRPRINT".equals(jcrDocDto.getsMIME().toUpperCase())) { wmcMedia.setMimeType(MediaFac.DATENFORMAT_MIMETYPE_APP_JASPER); wmcMedia.setOMedia(Helper.getBytesFromFile(file)); } else { wmcMedia.setMimeType(null); } } catch (Throwable e) { } }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
protected void eventActionUpdate(ActionEvent aE, boolean bNeedNoUpdateI) throws Throwable { bNewNode = false;/* ww w . j a v a 2 s . c o m*/ enableToolsPanelButtons(true, PanelBasis.ACTION_SAVE, PanelBasis.ACTION_DISCARD, BUTTON_SCAN); enableToolsPanelButtons(false, PanelBasis.ACTION_NEW, PanelBasis.ACTION_UPDATE); if (jcrDocDto.getlSicherheitsstufe() == JCRDocFac.SECURITY_ARCHIV) { wtfSchlagworte.setEditable(true); if (LPMain.getInstance().isLPAdmin()) { wcbSicherheitsstufe.setEnabled(true); } } else { enableAllComponents(this, true); } tree.setEnabled(false); wcbVersteckteAnzeigen.setEnabled(false); wtfName.setEditable(false); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.GERMANY); wdfZeitpunkt.setText(df.format(new Timestamp(System.currentTimeMillis()))); wtfAnleger.setText(personalDto.getCKurzzeichen()); }
From source file:org.nuclos.client.wizard.steps.NuclosEntityAttributeCommonPropertiesStep.java
@Override public void prepare() { super.prepare(); cbMandatory.setEnabled(true);//from ww w . j a v a 2 s . c o m fillCalcFunctionBox(); if (!this.parentWizardModel.isStateModel()) { cbxAttributeGroup.setEnabled(false); } else { fillAttributeGroupBox(); } if (getModel().getAttribute().getDatatyp().getJavaType().equals("java.lang.Integer")) { final NumericFormatDocument nfd = new NumericFormatDocument(); nfd.addDocumentListener(new DefaultValueDocumentListener()); tfDefaultValue.setDocument(nfd); final NumericFormatDocument nfdMandatory = new NumericFormatDocument(); nfdMandatory.addDocumentListener(new MandatoryValueDocumentListener()); tfMandatory.setDocument(nfdMandatory); } else if (getModel().getAttribute().getDatatyp().getJavaType().equals("java.lang.Double")) { final DoubleFormatDocument dfd = new DoubleFormatDocument(); dfd.addDocumentListener(new DefaultValueDocumentListener()); tfDefaultValue.setDocument(dfd); final DoubleFormatDocument dfdMandatory = new DoubleFormatDocument(); dfdMandatory.addDocumentListener(new MandatoryValueDocumentListener()); tfMandatory.setDocument(dfdMandatory); } if (getModel().isEditMode()) { tfLabel.setText(getModel().getAttribute().getInternalName()); cbxCalcFunction.setSelectedItem(getModel().getAttribute().getCalcFunction()); cbxAttributeGroup.setSelectedItem(getModel().getAttribute().getAttributeGroup()); cbDistinct.setSelected(getModel().getAttribute().isDistinct()); ItemListener ilArray[] = cbMandatory.getItemListeners(); for (ItemListener il : ilArray) { cbMandatory.removeItemListener(il); } cbMandatory.setSelected(getModel().getAttribute().isMandatory()); for (ItemListener il : ilArray) { cbMandatory.addItemListener(il); } cbLogBook.setSelected(getModel().getAttribute().isLogBook()); cbIndexed.setSelected(getModel().getAttribute().isIndexed()); if (getModel().getAttribute().getDatatyp().getJavaType().equals("java.util.Date")) { String str = getModel().getAttribute().getDefaultValue(); if (RelativeDate.today().toString().equals(str)) { dateDefaultValue.setDate(new Date(System.currentTimeMillis())); dateDefaultValue.getJTextField().setText("Heute"); } else if ("Heute".equalsIgnoreCase(str)) { dateDefaultValue.setDate(new Date(System.currentTimeMillis())); dateDefaultValue.getJTextField().setText("Heute"); } else { SimpleDateFormat result = new SimpleDateFormat("dd.MM.yyyy", Locale.GERMANY); result.setLenient(false); try { dateDefaultValue.setDate(result.parse(str)); } catch (Exception e) { // set no day LOG.warn("prepare failed: " + e, e); } } } else if (getModel().getAttribute().getDatatyp().getJavaType().equals("java.lang.Boolean")) { String value = getModel().getAttribute().getDefaultValue(); if (value != null && value.equalsIgnoreCase("ja")) { cbDefaultValue.setSelected(true); } else { cbDefaultValue.setSelected(false); } } else { tfDefaultValue.setText(getModel().getAttribute().getDefaultValue()); } if (getModel().getAttribute().getDbName() != null) { String sModifiedDBName = new String(getModel().getAttribute().getDbName()); tfDBFieldName.setText(sModifiedDBName.replaceFirst("^STRVALUE_", "").replaceFirst("^INTID_", "")); if (getModel().getAttribute().getMetaVO() != null && getModel().getAttribute().getField() != null) { tfDBFieldNameComplete.setText("STRVALUE_" + getModel().getAttribute().getDbName()); } else if (getModel().getAttribute().getMetaVO() != null && getModel().getAttribute().getField() == null) { tfDBFieldNameComplete.setText("INTID_" + getModel().getAttribute().getDbName()); } } } else { if (!blnLabelModified) tfLabel.setText(getModel().getName().toLowerCase()); if (getModel().getAttributeCount() == 0 && !blnDefaultSelected) { cbDistinct.setSelected(true); cbMandatory.setSelected(true); blnDefaultSelected = true; } cbDistinct.setEnabled(!this.parentWizardModel.hasRows()); cbIndexed.setSelected(getModel().isRefernzTyp()); if (cbxAttributeGroup.getModel().getSize() > 1) { if (this.parentWizardModel.isStateModel()) cbxAttributeGroup.setSelectedIndex(1); } if (getModel().getAttribute().getDbName() != null) { String sModifiedDBName = new String(getModel().getAttribute().getDbName()); tfDBFieldName.setText(sModifiedDBName.replaceFirst("^STRVALUE_", "").replaceFirst("^INTID_", "")); if (getModel().getAttribute().getMetaVO() != null && getModel().getAttribute().getField() != null) { tfDBFieldNameComplete.setText("STRVALUE_" + getModel().getAttribute().getDbName()); } else if (getModel().getAttribute().getMetaVO() != null && getModel().getAttribute().getField() == null) { tfDBFieldNameComplete.setText("INTID_" + getModel().getAttribute().getDbName()); } } } Object objMandatoryValue = getModel().getAttribute().getMandatoryValue(); if (getModel().isRefernzTyp() || getModel().isLookupTyp()) { ItemListener listener[] = cbxDefaultValue.getItemListeners(); for (ItemListener il : listener) { cbxDefaultValue.removeItemListener(il); } ItemListener listenerMandatory[] = cbxDefaultValue.getItemListeners(); for (ItemListener il : listenerMandatory) { cbxMandatory.removeItemListener(il); } boolean isValueList = getModel().getAttribute().isValueListProvider(); cbxDefaultValue.setVisible(!isValueList); lovDefaultValue.setVisible(isValueList); tfDefaultValue.setVisible(false); dateDefaultValue.setVisible(false); cbDefaultValue.setVisible(false); cbxMandatory.setVisible(!isValueList && this.parentWizardModel.isEditMode()); lovMandatory.setVisible(isValueList && this.parentWizardModel.isEditMode()); tfMandatory.setVisible(false); dateMandatory.setVisible(false); cbMandatoryValue.setVisible(false); List<DefaultValue> defaultModel = new ArrayList<DefaultValue>(); List<DefaultValue> mandatoryModel = new ArrayList<DefaultValue>(); DefaultValue mandatoryValue = null; final String sEntity = !getModel().isLookupTyp() ? getModel().getAttribute().getMetaVO().getEntity() : getModel().getAttribute().getLookupMetaVO().getEntity(); if (!isValueList) { Collection<MasterDataVO> colVO = MasterDataDelegate.getInstance().getMasterData(sEntity); for (MasterDataVO vo : colVO) { String sField = getModel().getAttribute().getField(); if (sField == null) break; Pattern referencedEntityPattern = Pattern.compile("[$][{][\\w\\[\\]]+[}]"); Matcher referencedEntityMatcher = referencedEntityPattern.matcher(sField); StringBuffer sb = new StringBuffer(); while (referencedEntityMatcher.find()) { Object value = referencedEntityMatcher.group().substring(2, referencedEntityMatcher.group().length() - 1); String sName = value.toString(); Object fieldValue = vo.getField(sName); if (fieldValue != null) referencedEntityMatcher.appendReplacement(sb, fieldValue.toString()); else referencedEntityMatcher.appendReplacement(sb, ""); } // complete the transfer to the StringBuffer referencedEntityMatcher.appendTail(sb); sField = sb.toString(); DefaultValue dv = new DefaultValue(vo.getIntId(), sField); defaultModel.add(dv); mandatoryModel.add(dv); if (dv.getId().equals(objMandatoryValue)) { mandatoryValue = dv; } } Collections.sort(defaultModel); Collections.sort(mandatoryModel); defaultModel.add(0, new DefaultValue(null, null)); mandatoryModel.add(0, new DefaultValue(null, null)); cbxDefaultValue.setModel(new ListComboBoxModel<DefaultValue>(defaultModel)); cbxDefaultValue.setSelectedItem(getModel().getAttribute().getIdDefaultValue()); cbxMandatory.setModel(new ListComboBoxModel<DefaultValue>(mandatoryModel)); if (mandatoryValue != null) { cbxMandatory.setSelectedItem(mandatoryValue); } for (ItemListener il : listener) { cbxDefaultValue.addItemListener(il); } for (ItemListener il : listenerMandatory) { cbxMandatory.addItemListener(il); } } else { final EntityFieldMetaDataVO efMetaDataVO = new EntityFieldMetaDataVO(); efMetaDataVO.setField(sEntity); efMetaDataVO.setDataType(String.class.getName()); efMetaDataVO.setForeignEntity(sEntity); efMetaDataVO.setForeignEntityField(getModel().getAttribute().getField()); lovDefaultValue.setModel(getModel()); lovDefaultValue.setEfMetaDataVO(efMetaDataVO); lovDefaultValue.setSelectedListener(new ListOfValues.SelectedListener() { @Override public void actionPerformed(CollectableValueIdField itemSelected) { if (itemSelected == null) { getModel().getAttribute().setIdDefaultValue(new DefaultValue(null, null)); } else { getModel().getAttribute().setIdDefaultValue( new DefaultValue(IdUtils.unsafeToId(itemSelected.getValueId()), (String) itemSelected.getValue())); } } }); lovMandatory.setModel(getModel()); lovMandatory.setEfMetaDataVO(efMetaDataVO); lovMandatory.setSelectedListener(new ListOfValues.SelectedListener() { @Override public void actionPerformed(CollectableValueIdField itemSelected) { if (itemSelected == null) { getModel().getAttribute().setMandatoryValue(new DefaultValue(null, null).getId()); } else { getModel().getAttribute().setMandatoryValue( new DefaultValue(IdUtils.unsafeToId(itemSelected.getValueId()), (String) itemSelected.getValue()).getId()); } } }); } } else if (getModel().getAttribute().getDatatyp().getJavaType().equals("java.util.Date")) { dateDefaultValue.setVisible(true); cbxDefaultValue.setVisible(false); lovDefaultValue.setVisible(false); tfDefaultValue.setVisible(false); cbDefaultValue.setVisible(false); cbxMandatory.setVisible(false); lovMandatory.setVisible(false); tfMandatory.setVisible(false); dateMandatory.setVisible(this.parentWizardModel.isEditMode()); if (objMandatoryValue != null && objMandatoryValue instanceof Date) { dateMandatory.setDate((Date) objMandatoryValue); } cbMandatoryValue.setVisible(false); } else if (getModel().getAttribute().getDatatyp().getJavaType().equals("java.lang.Boolean")) { cbxDefaultValue.setVisible(false); lovDefaultValue.setVisible(false); tfDefaultValue.setVisible(false); dateDefaultValue.setVisible(false); cbDefaultValue.setVisible(true); cbxMandatory.setVisible(false); lovMandatory.setVisible(false); tfMandatory.setVisible(false); dateMandatory.setVisible(false); cbMandatoryValue.setVisible(this.parentWizardModel.isEditMode()); if (objMandatoryValue != null && objMandatoryValue instanceof Boolean) { cbMandatoryValue.setSelected((Boolean) objMandatoryValue); } } else if (getModel().getAttribute().isValueList()) { ItemListener listener[] = cbxDefaultValue.getItemListeners(); for (ItemListener il : listener) { cbxDefaultValue.removeItemListener(il); } cbxCalcFunction.setEnabled(false); cbxDefaultValue.setVisible(true); lovDefaultValue.setVisible(false); tfDefaultValue.setVisible(false); dateDefaultValue.setVisible(false); cbDefaultValue.setVisible(false); cbxDefaultValue.removeAllItems(); cbxDefaultValue.addItem(new DefaultValue(null, null)); cbxMandatory.addItem(new DefaultValue(null, null)); for (ValueList valueList : getModel().getAttribute().getValueList()) { cbxDefaultValue.addItem(new DefaultValue( valueList.getId() != null ? valueList.getId().intValue() : null, valueList.getLabel())); } cbxDefaultValue.setSelectedItem(getModel().getAttribute().getDefaultValue()); for (ItemListener il : listener) { cbxDefaultValue.addItemListener(il); } listener = cbxMandatory.getItemListeners(); for (ItemListener il : listener) { cbxMandatory.removeItemListener(il); } for (ValueList valueList : getModel().getAttribute().getValueList()) { DefaultValue dv = new DefaultValue(valueList.getId() != null ? valueList.getId().intValue() : null, valueList.getLabel()); cbxMandatory.addItem(dv); if (dv.getId() != null && dv.getId().equals(objMandatoryValue)) { cbxMandatory.setSelectedItem(dv); } } for (ItemListener il : listener) { cbxMandatory.addItemListener(il); } cbMandatory.setEnabled(getModel().getAttribute().getId() != null); cbxMandatory.setVisible(true); lovMandatory.setVisible(parentWizardModel.isEditMode() && getModel().getAttribute().getId() != null); tfMandatory.setVisible(false); dateMandatory.setVisible(false); cbMandatoryValue.setVisible(false); } else if (getModel().getAttribute().isImage() || getModel().getAttribute().isPasswordField() || getModel().getAttribute().isFileType()) { cbMandatory.setEnabled(false); cbxMandatory.setVisible(false); lovMandatory.setVisible(false); tfMandatory.setVisible(false); dateMandatory.setVisible(false); cbMandatoryValue.setVisible(false); } else { cbxDefaultValue.setVisible(false); lovDefaultValue.setVisible(false); tfDefaultValue.setVisible(true); dateDefaultValue.setVisible(false); cbDefaultValue.setVisible(false); cbxMandatory.setVisible(false); lovMandatory.setVisible(false); tfMandatory.setVisible(this.parentWizardModel.isEditMode()); if (objMandatoryValue != null) { tfMandatory.setText(objMandatoryValue.toString()); } dateMandatory.setVisible(false); cbMandatoryValue.setVisible(false); } Attribute attr = NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute(); if (NuclosEntityAttributeCommonPropertiesStep.this.parentWizardModel.hasRows() && attr.getId() != null) { boolean blnAllowed = StringUtils.isEmpty(attr.getInternalName()) ? false : MetaDataDelegate.getInstance().isChangeDatabaseColumnToUniqueAllowed( NuclosEntityAttributeCommonPropertiesStep.this.parentWizardModel.getEntityName(), attr.getInternalName()); if (!blnAllowed && !attr.isDistinct()) { cbDistinct.setSelected(false); cbDistinct.setEnabled(false); cbDistinct.setToolTipText(SpringLocaleDelegate.getInstance().getMessage( "wizard.step.entitysqllayout.6", "Das Feld {0} kann nicht auf ein eindeutiges Feld umgestellt werden.", attr.getLabel())); } } if (parentWizardModel.isVirtual()) { cbDistinct.setSelected(false); cbDistinct.setEnabled(false); tfMandatory.setEnabled(false); dateMandatory.setEnabled(false); cbMandatory.setEnabled(false); cbxMandatory.setEnabled(false); cbMandatoryValue.setEnabled(false); cbxCalcFunction.setEnabled(false); tfDBFieldName.setEnabled(false); cbIndexed.setEnabled(false); tfDefaultValue.setEnabled(false); dateDefaultValue.setEnabled(false); cbxDefaultValue.setEnabled(false); cbDefaultValue.setEnabled(false); cbLogBook.setEnabled(false); } }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
public void setDefaultsForNew() throws Throwable { wtfAnleger.setText(personalDto.getCKurzzeichen()); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.GERMANY); wdfZeitpunkt.setText(df.format(new Timestamp(System.currentTimeMillis()))); wtfFilename.setText(file.getName()); wtfMIME.setText(Helper.getMime(file.getName())); wcbVersteckt.setSelected(false);// w w w . ja v a2s . c o m if (bHatStufe3) { wcbSicherheitsstufe.setSelectedItem(JCRDocFac.SECURITY_HIGH); } else if (bHatStufe2) { wcbSicherheitsstufe.setSelectedItem(JCRDocFac.SECURITY_MEDIUM); } else if (bHatStufe1) { wcbSicherheitsstufe.setSelectedItem(JCRDocFac.SECURITY_LOW); } else if (bHatStufe0) { wcbSicherheitsstufe.setSelectedItem(JCRDocFac.SECURITY_NONE); } wcbSicherheitsstufe.removeItem(JCRDocFac.SECURITY_ARCHIV); wcbBelegart.removeItem(JCRDocFac.DEFAULT_ARCHIV_BELEGART); wtfBelegnummer.setText(tree.getLastSelectedPathComponent().toString()); wtfTable.setText(sTable); wtfRow.setText(sRow); wtfPartner.setText(partnerDto.formatFixTitelName1Name2()); }
From source file:de.bangl.lm.LotManagerPlugin.java
public String formatPrice(Double price) { String result = ""; result = String.format(Locale.GERMANY, "%.2f", price); result = StringUtils.removeEnd(result, ".00"); result = StringUtils.removeEnd(result, ",00"); result = result + " " + eco.currencyNamePlural(); return result; }
From source file:org.openmrs.api.ConceptServiceTest.java
/** * @see ConceptService#getConceptStopWords(Locale) *//*from www . jav a 2 s .c o m*/ @Test @Verifies(value = "should return empty list if no stop words are found for the given locale", method = "getConceptStopWords(Locale)") public void getConceptStopWords_shouldReturnEmptyListIfNoConceptStopWordsForGivenLocale() throws Exception { List<String> conceptStopWords = conceptService.getConceptStopWords(Locale.GERMANY); assertEquals(0, conceptStopWords.size()); }
From source file:de.innovationgate.wgpublisher.lucene.LuceneManager.java
public WGResultSet search(WGDatabase db, List<String> fields, String phrase, Map parameters, WGA wga) throws WGQueryException { if (wga == null) { wga = WGA.get(_core);/*from w w w . j a va 2 s. c o m*/ } // set max clause count for boolean queries BooleanQuery.setMaxClauseCount(_booleanQueryMaxClauseCount); if (this.isRebuildingIndex()) { throw new WGQueryException(phrase, "Lucene search temporary disabled. Rebuilding lucene index ..."); } // Registering problem in that case but not cancelling the query, as this is old, expected behaviour. The query will just return no results. if (!_core.getLuceneManager().indexIsEnabled(db.getDbReference())) { _core.getProblemRegistry().addProblem( Problem.create(new TMLContext.WebTMLOccasion(), new DatabaseScope(db.getDbReference()), "webtmlProblem.luceneIndexExpected", ProblemSeverity.LOW)); } if (phrase == null || phrase.trim().equals("")) { return null; } try { BooleanQuery wholeQuery = new BooleanQuery(); int max = WGACore.DEFAULT_QUERY_MAXRESULTS; Integer maxResults = (Integer) parameters.get(WGDatabase.QUERYOPTION_MAXRESULTS); if (maxResults != null) { if (maxResults == 0 || maxResults == -1) { max = Integer.MAX_VALUE; } else { max = maxResults; } } // handle dboption EXCLUDEDOCUMENT WGContent excludeContent = (WGContent) parameters.get(WGDatabase.QUERYOPTION_EXCLUDEDOCUMENT); if (excludeContent != null) { String uniqueKey = buildUniqueIndexKey(excludeContent.getDatabase().getDbReference(), excludeContent.getDocumentKey()); wholeQuery.add(new TermQuery(new Term(INDEXFIELD_UNIQUEKEY, uniqueKey)), BooleanClause.Occur.MUST_NOT); wholeQuery.add(new TermQuery(new Term(INDEXFIELD_PARENTKEY, uniqueKey)), BooleanClause.Occur.MUST_NOT); } // list of dbs to search in String searchScope = (String) parameters.get(LuceneManager.QUERYOPTION_SEARCHSCOPE); List searchDBKeys = new ArrayList(); if (searchScope.equals(LuceneManager.SEARCHSCOPE_DB)) { searchDBKeys.add(db.getDbReference()); } if (searchScope.equals(LuceneManager.SEARCHSCOPE_DOMAIN)) { Iterator<WGDatabase> dbs = _core .getDatabasesForDomain((String) db.getAttribute(WGACore.DBATTRIB_DOMAIN)).iterator(); while (dbs.hasNext()) { WGDatabase currentDB = dbs.next(); if (wga.openDatabase(currentDB)) { searchDBKeys.add(currentDB.getDbReference()); } } } if (searchScope.equals(LuceneManager.SEARCHSCOPE_WGA)) { Iterator dbs = _core.getContentdbs().values().iterator(); while (dbs.hasNext()) { WGDatabase currentDB = (WGDatabase) dbs.next(); if (wga.openDatabase(currentDB)) { searchDBKeys.add(currentDB.getDbReference()); } } } if (searchScope.equals(LuceneManager.SEARCHSCOPE_DB_LIST)) { String dbListCSV = (String) parameters.get(QUERYOPTION_SEARCHDBKEYS); if (dbListCSV == null || dbListCSV.trim().equals("")) { throw new WGQueryException(phrase, "Search scope is 'dblist' but no db keys given."); } else { Iterator dbkeys = WGUtils.deserializeCollection(dbListCSV, ",").iterator(); while (dbkeys.hasNext()) { String dbkey = (String) dbkeys.next(); WGDatabase currentDB = wga.db(dbkey); if (currentDB.isSessionOpen()) { searchDBKeys.add(dbkey.trim().toLowerCase()); } } } } // Handle language selection; List<WGLanguage> languagesPriorityList = null; boolean filterLanguages = false; if (parameters.containsKey(WGDatabase.QUERYOPTION_LANGUAGES)) { List<WGLanguage> langs = (List<WGLanguage>) parameters.get(WGDatabase.QUERYOPTION_LANGUAGES); if (langs.size() > 1) { BooleanQuery langQuery = new BooleanQuery(); for (WGLanguage lang : langs) { langQuery.add(new TermQuery(new Term(WGContent.META_LANGUAGE, lang.getName())), BooleanClause.Occur.SHOULD); } wholeQuery.add(langQuery, BooleanClause.Occur.MUST); languagesPriorityList = langs; filterLanguages = true; } else if (langs.size() == 1) { wholeQuery.add(new TermQuery(new Term(WGContent.META_LANGUAGE, langs.get(0).getName())), BooleanClause.Occur.MUST); languagesPriorityList = Collections.singletonList(langs.get(0)); } } else if (parameters.containsKey(WGDatabase.QUERYOPTION_ONLYLANGUAGE)) { String language = (String) parameters.get(WGDatabase.QUERYOPTION_ONLYLANGUAGE); wholeQuery.add(new TermQuery(new Term(WGContent.META_LANGUAGE, language)), BooleanClause.Occur.MUST); languagesPriorityList = Collections.singletonList(db.getLanguage(language)); } if (languagesPriorityList == null) { languagesPriorityList = getLanguagesForSearchDBKeys(searchDBKeys); ; } // Handle visibility selection if (!parameters.containsKey(WGDatabase.QUERYOPTION_ENHANCE) || parameters.get(WGDatabase.QUERYOPTION_ENHANCE).equals(new Boolean(true))) { wholeQuery.add(new TermQuery(new Term(WGContent.META_VISIBLE, "true")), BooleanClause.Occur.MUST); String role = (String) parameters.get(WGDatabase.QUERYOPTION_ROLE); if (role != null) { if (!role.equalsIgnoreCase(WGContent.DISPLAYTYPE_NONE)) { wholeQuery.add(new TermQuery(new Term("HIDDENIN" + role.toUpperCase(), "false")), BooleanClause.Occur.MUST); } } } if (parameters.containsKey(WGDatabase.QUERYOPTION_ONLYRELEASED)) { wholeQuery.add(new TermQuery(new Term(WGContent.META_STATUS, WGContent.STATUS_RELEASE)), BooleanClause.Occur.MUST); } // build dbQuery (OR combination of all searchDbs indexed by lucene) BooleanQuery dbQuery = new BooleanQuery(); Iterator itSearchDBKeys = searchDBKeys.iterator(); while (itSearchDBKeys.hasNext()) { String currentDBKey = (String) itSearchDBKeys.next(); if (_indexedDbs.containsKey(currentDBKey)) { dbQuery.add(new TermQuery(new Term(INDEXFIELD_DBKEY, currentDBKey)), BooleanClause.Occur.SHOULD); } } wholeQuery.add(dbQuery, BooleanClause.Occur.MUST); // Add parsed search phrase. // Search in allcontent for each language using the configured analyzer // if no analyzer is configured for a language search at least with one // default analyzer boolean searchWithDefaultAnalyzer = false; //if no languages found search at least with DefaultAnalyzer if (languagesPriorityList.size() <= 0) { searchWithDefaultAnalyzer = true; } // parse native options Sort sort = null; String sortFieldName = ""; Operator defaultOperator = QueryParser.AND_OPERATOR; String nativeOptionsStr = (String) parameters.get(WGDatabase.QUERYOPTION_NATIVEOPTIONS); boolean includeVirtualContent = false; String doctype = DOCTYPE_CONTENT; if (nativeOptionsStr != null) { Iterator nativeOptions = WGUtils.deserializeCollection(nativeOptionsStr, ",", true).iterator(); while (nativeOptions.hasNext()) { String option = (String) nativeOptions.next(); if (option.startsWith("sort:")) { sortFieldName = option.substring(5).trim(); boolean reverse = false; if (sortFieldName.toLowerCase().endsWith("(asc)")) { sortFieldName = sortFieldName.substring(0, sortFieldName.length() - 5).trim(); } else if (sortFieldName.toLowerCase().endsWith("(desc)")) { sortFieldName = sortFieldName.substring(0, sortFieldName.length() - 6).trim(); reverse = true; } if (sortFieldName.length() > 0) { char first = sortFieldName.charAt(0); if (first >= 'A' && first <= 'Z') { // meta sort sortFieldName = sortFieldName.toUpperCase(); } else { // item sort sortFieldName = sortFieldName.toLowerCase(); } } // sort order currently only german sort = new Sort(new SortField(SORTITEM_PREFIX + sortFieldName, Locale.GERMANY, reverse)); } else if (option.equalsIgnoreCase(NATIVE_QUERYOPTION_INCLUDEVIRTUALCONTENT)) { includeVirtualContent = true; } else if (option.startsWith("doctype:")) { doctype = option.substring("doctype:".length()).trim(); } else if (option.startsWith("operator:")) { String op = option.substring("operator:".length()).trim(); if (op.equalsIgnoreCase("or")) defaultOperator = QueryParser.OR_OPERATOR; } } } if (!includeVirtualContent) { wholeQuery.add(new TermQuery(new Term(INDEXFIELD_ISVIRTUALCONTENT, String.valueOf(true))), BooleanClause.Occur.MUST_NOT); } // handle doctype option // we cannot be sure that all documents in index already contains the field DOCTYPE (introduced with OpenWGA 7.1) therefore we have to perform some excludes if (doctype.equals(DOCTYPE_CONTENT)) { wholeQuery.add(new TermQuery(new Term(INDEXFIELD_DOCTYPE, DOCTYPE_ATTACHMENT)), BooleanClause.Occur.MUST_NOT); } else if (!doctype.equals(DOCTYPE_ALL)) { wholeQuery.add(new TermQuery(new Term(INDEXFIELD_DOCTYPE, doctype)), BooleanClause.Occur.MUST); } //build phrase query BooleanQuery phraseQuery = new BooleanQuery(); phraseQuery.setBoost(10); Iterator languageList = languagesPriorityList.iterator(); List<String> searchFields = new ArrayList<String>(); Map<String, Float> searchBoosts = new HashMap<String, Float>(); for (String field : fields) { String[] parts = field.split("\\^"); searchFields.add(parts[0]); if (parts.length == 2) { searchBoosts.put(parts[0], Float.parseFloat(parts[1])); } } if (!searchFields.contains("allcontent")) searchFields.add("allcontent"); if (!searchFields.contains("TITLE")) searchFields.add("TITLE"); if (!searchFields.contains("DESCRIPTION")) searchFields.add("DESCRIPTION"); if (!searchFields.contains("KEYWORDS")) searchFields.add("KEYWORDS"); while (languageList.hasNext()) { WGLanguage languageItem = (WGLanguage) languageList.next(); Analyzer analyzer = _core.getAnalyzerForLanguageCode(languageItem.getName().substring(0, 2)); if (analyzer != null) { QueryParser parser = new IndexingRuleBasedQueryParser(searchFields.toArray(new String[0]), analyzer, searchBoosts, _indexedDbs, searchDBKeys, _metaKeywordFields); parser.setDefaultOperator(defaultOperator); Query query = parser.parse(phrase); if (filterLanguages) { BooleanQuery testPhraseAndLangQuery = new BooleanQuery(); testPhraseAndLangQuery.add(query, BooleanClause.Occur.MUST); testPhraseAndLangQuery.add( new TermQuery(new Term(WGContent.META_LANGUAGE, languageItem.getName())), BooleanClause.Occur.MUST); phraseQuery.add(testPhraseAndLangQuery, BooleanClause.Occur.SHOULD); } else { phraseQuery.add(query, BooleanClause.Occur.SHOULD); } } else { searchWithDefaultAnalyzer = true; } } if (searchWithDefaultAnalyzer) { QueryParser parser = new IndexingRuleBasedQueryParser(searchFields.toArray(new String[0]), _core.getDefaultAnalyzer(), searchBoosts, _indexedDbs, searchDBKeys, _metaKeywordFields); parser.setDefaultOperator(defaultOperator); Query query = parser.parse(phrase); phraseQuery.add(query, BooleanClause.Occur.SHOULD); } //LOG.info(phraseQuery.toString()); wholeQuery.add(phraseQuery, BooleanClause.Occur.MUST); TopDocs hits; //register executed query as output parameter parameters.put(WGDatabase.QUERYOPTION_RETURNQUERY, wholeQuery.toString()); // simplify query and register as taginfo parameters.put(TAGINFO_SIMPLIFIEDQUERY, rewrite(wholeQuery)); long timeBefore = System.currentTimeMillis(); if (sort != null) { try { hits = search(wholeQuery, max, sort); } catch (NullPointerException e) { // lucene bug when sorting for non existing fields with Locale throw new WGQueryException(wholeQuery.toString(), "Sortfield '" + sortFieldName + "' not indexed."); } } else { try { hits = search(wholeQuery, max, null); } catch (BooleanQuery.TooManyClauses e) { parameters.put(TAGINFO_UNSPECIFICQUERY, new Boolean(true)); throw new WGQueryException(phrase, "Too many BooleanClauses in query. " + "Please use a more specific query or increase value of " + "'booleanQueryMaxClauseCount' via WGAManager. Current value is '" + this.getBooleanQueryMaxClauseCount() + "'."); } } long timeAfter = System.currentTimeMillis(); long executionTime = timeAfter - timeBefore; LuceneResultSet resultSet; if (filterLanguages) { resultSet = new LuceneLanguageChoosingResultSet(hits, wga, parameters, wholeQuery, executionTime, languagesPriorityList); } else { resultSet = new LuceneMultiDBResultSet(hits, wga, parameters, wholeQuery, executionTime); } // put resultset in per thread list List rsList = (List) _resultsetList.get(); if (rsList == null) { rsList = new LinkedList(); _resultsetList.set(rsList); } rsList.add(resultSet); return resultSet; } catch (org.apache.lucene.queryParser.ParseException e) { throw new WGQueryException("Unable to parse lucene query", e.getMessage(), e); } catch (Exception e) { LOG.error("Error executing lucene search: " + e.getClass().getName() + " - " + e.getMessage(), e); throw new WGQueryException(phrase, e.getClass().getName() + ": " + e.getMessage(), e); } }