List of usage examples for java.text Collator getInstance
public static Collator getInstance(Locale desiredLocale)
From source file:org.apache.nifi.web.controller.ControllerFacade.java
/** * Creates a ProvenanceEventDTO for the specified ProvenanceEventRecord. * * @param event event/*from ww w . ja v a 2 s . com*/ * @return event */ private ProvenanceEventDTO createProvenanceEventDto(final ProvenanceEventRecord event, final boolean summarize) { final ProvenanceEventDTO dto = new ProvenanceEventDTO(); dto.setId(String.valueOf(event.getEventId())); dto.setEventId(event.getEventId()); dto.setEventTime(new Date(event.getEventTime())); dto.setEventType(event.getEventType().name()); dto.setFlowFileUuid(event.getFlowFileUuid()); dto.setFileSize(FormatUtils.formatDataSize(event.getFileSize())); dto.setFileSizeBytes(event.getFileSize()); dto.setComponentId(event.getComponentId()); dto.setComponentType(event.getComponentType()); // sets the component details if it can find the component still in the flow setComponentDetails(dto); // only include all details if not summarizing if (!summarize) { // convert the attributes final Comparator<AttributeDTO> attributeComparator = new Comparator<AttributeDTO>() { @Override public int compare(AttributeDTO a1, AttributeDTO a2) { return Collator.getInstance(Locale.US).compare(a1.getName(), a2.getName()); } }; final SortedSet<AttributeDTO> attributes = new TreeSet<>(attributeComparator); final Map<String, String> updatedAttrs = event.getUpdatedAttributes(); final Map<String, String> previousAttrs = event.getPreviousAttributes(); // add previous attributes that haven't been modified. for (final Map.Entry<String, String> entry : previousAttrs.entrySet()) { // don't add any attributes that have been updated; we will do that next if (updatedAttrs.containsKey(entry.getKey())) { continue; } final AttributeDTO attribute = new AttributeDTO(); attribute.setName(entry.getKey()); attribute.setValue(entry.getValue()); attribute.setPreviousValue(entry.getValue()); attributes.add(attribute); } // Add all of the update attributes for (final Map.Entry<String, String> entry : updatedAttrs.entrySet()) { final AttributeDTO attribute = new AttributeDTO(); attribute.setName(entry.getKey()); attribute.setValue(entry.getValue()); attribute.setPreviousValue(previousAttrs.get(entry.getKey())); attributes.add(attribute); } // additional event details dto.setAlternateIdentifierUri(event.getAlternateIdentifierUri()); dto.setAttributes(attributes); dto.setTransitUri(event.getTransitUri()); dto.setSourceSystemFlowFileId(event.getSourceSystemFlowFileIdentifier()); dto.setRelationship(event.getRelationship()); dto.setDetails(event.getDetails()); final ContentAvailability contentAvailability = flowController.getContentAvailability(event); // content dto.setContentEqual(contentAvailability.isContentSame()); dto.setInputContentAvailable(contentAvailability.isInputAvailable()); dto.setInputContentClaimSection(event.getPreviousContentClaimSection()); dto.setInputContentClaimContainer(event.getPreviousContentClaimContainer()); dto.setInputContentClaimIdentifier(event.getPreviousContentClaimIdentifier()); dto.setInputContentClaimOffset(event.getPreviousContentClaimOffset()); dto.setInputContentClaimFileSizeBytes(event.getPreviousFileSize()); dto.setOutputContentAvailable(contentAvailability.isOutputAvailable()); dto.setOutputContentClaimSection(event.getContentClaimSection()); dto.setOutputContentClaimContainer(event.getContentClaimContainer()); dto.setOutputContentClaimIdentifier(event.getContentClaimIdentifier()); dto.setOutputContentClaimOffset(event.getContentClaimOffset()); dto.setOutputContentClaimFileSize(FormatUtils.formatDataSize(event.getFileSize())); dto.setOutputContentClaimFileSizeBytes(event.getFileSize()); // format the previous file sizes if possible if (event.getPreviousFileSize() != null) { dto.setInputContentClaimFileSize(FormatUtils.formatDataSize(event.getPreviousFileSize())); } // determine if authorized for event replay final AuthorizationResult replayAuthorized = checkAuthorizationForReplay(event); // replay dto.setReplayAvailable( contentAvailability.isReplayable() && Result.Approved.equals(replayAuthorized.getResult())); dto.setReplayExplanation( contentAvailability.isReplayable() && !Result.Approved.equals(replayAuthorized.getResult()) ? replayAuthorized.getExplanation() : contentAvailability.getReasonNotReplayable()); dto.setSourceConnectionIdentifier(event.getSourceQueueIdentifier()); // event duration if (event.getEventDuration() >= 0) { dto.setEventDuration(event.getEventDuration()); } // lineage duration if (event.getLineageStartDate() > 0) { final long lineageDuration = event.getEventTime() - event.getLineageStartDate(); dto.setLineageDuration(lineageDuration); } // parent uuids final List<String> parentUuids = new ArrayList<>(event.getParentUuids()); Collections.sort(parentUuids, Collator.getInstance(Locale.US)); dto.setParentUuids(parentUuids); // child uuids final List<String> childUuids = new ArrayList<>(event.getChildUuids()); Collections.sort(childUuids, Collator.getInstance(Locale.US)); dto.setChildUuids(childUuids); } return dto; }
From source file:org.apache.nifi.web.api.dto.DtoFactory.java
private Set<ControllerServiceReferencingComponentDTO> createControllerServiceReferencingComponentsDto( final ControllerServiceReference reference, final Set<ControllerServiceNode> visited) { final Set<ControllerServiceReferencingComponentDTO> referencingComponents = new LinkedHashSet<>(); // get all references for (final ConfiguredComponent component : reference.getReferencingComponents()) { final ControllerServiceReferencingComponentDTO dto = new ControllerServiceReferencingComponentDTO(); dto.setId(component.getIdentifier()); dto.setName(component.getName()); List<PropertyDescriptor> propertyDescriptors = null; Collection<ValidationResult> validationErrors = null; if (component instanceof ProcessorNode) { final ProcessorNode node = ((ProcessorNode) component); dto.setGroupId(node.getProcessGroup().getIdentifier()); dto.setState(node.getScheduledState().name()); dto.setActiveThreadCount(node.getActiveThreadCount()); dto.setType(node.getProcessor().getClass().getName()); dto.setReferenceType(Processor.class.getSimpleName()); propertyDescriptors = node.getProcessor().getPropertyDescriptors(); validationErrors = node.getValidationErrors(); } else if (component instanceof ControllerServiceNode) { final ControllerServiceNode node = ((ControllerServiceNode) component); dto.setState(node.getState().name()); dto.setType(node.getControllerServiceImplementation().getClass().getName()); dto.setReferenceType(ControllerService.class.getSimpleName()); dto.setReferenceCycle(visited.contains(node)); // if we haven't encountered this service before include it's referencing components if (!dto.getReferenceCycle()) { dto.setReferencingComponents( createControllerServiceReferencingComponentsDto(node.getReferences(), visited)); }//from w ww. j av a2 s . c o m propertyDescriptors = node.getControllerServiceImplementation().getPropertyDescriptors(); validationErrors = node.getValidationErrors(); } else if (component instanceof ReportingTaskNode) { final ReportingTaskNode node = ((ReportingTaskNode) component); dto.setState(node.getScheduledState().name()); dto.setActiveThreadCount(node.getActiveThreadCount()); dto.setType(node.getReportingTask().getClass().getName()); dto.setReferenceType(ReportingTask.class.getSimpleName()); propertyDescriptors = node.getReportingTask().getPropertyDescriptors(); validationErrors = node.getValidationErrors(); } if (propertyDescriptors != null && !propertyDescriptors.isEmpty()) { final Map<PropertyDescriptor, String> sortedProperties = new TreeMap<>( new Comparator<PropertyDescriptor>() { @Override public int compare(PropertyDescriptor o1, PropertyDescriptor o2) { return Collator.getInstance(Locale.US).compare(o1.getName(), o2.getName()); } }); sortedProperties.putAll(component.getProperties()); final Map<PropertyDescriptor, String> orderedProperties = new LinkedHashMap<>(); for (PropertyDescriptor descriptor : propertyDescriptors) { orderedProperties.put(descriptor, null); } orderedProperties.putAll(sortedProperties); // build the descriptor and property dtos dto.setDescriptors(new LinkedHashMap<String, PropertyDescriptorDTO>()); dto.setProperties(new LinkedHashMap<String, String>()); for (final Map.Entry<PropertyDescriptor, String> entry : orderedProperties.entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); // store the property descriptor dto.getDescriptors().put(descriptor.getName(), createPropertyDescriptorDto(descriptor)); // determine the property value - don't include sensitive properties String propertyValue = entry.getValue(); if (propertyValue != null && descriptor.isSensitive()) { propertyValue = "********"; } // set the property value dto.getProperties().put(descriptor.getName(), propertyValue); } } if (validationErrors != null && !validationErrors.isEmpty()) { final List<String> errors = new ArrayList<>(); for (final ValidationResult validationResult : validationErrors) { errors.add(validationResult.toString()); } dto.setValidationErrors(errors); } referencingComponents.add(dto); } return referencingComponents; }
From source file:org.nuclos.client.main.MainController.java
public List<GenericAction> getGenericActions() { List<GenericAction> result = new ArrayList<GenericAction>(); getFileMenuActions(result);/*from ww w . j a v a2 s . c om*/ getAdministrationMenuActions(result); getConfigurationMenuActions(result); //getHelpMenuActions(result); List<GenericAction> sortedResult = new ArrayList<GenericAction>(); getEntityMenuActions(sortedResult); getNucletComponentMenuActions(sortedResult); getCustomComponentMenuActions(sortedResult); getTasklistMenuActions(sortedResult); final Collator collator = Collator.getInstance(Locale.getDefault()); final Comparator<String[]> arrayCollator = ComparatorUtils.arrayComparator(collator); Collections.sort(sortedResult, new Comparator<GenericAction>() { @Override public int compare(GenericAction p1, GenericAction p2) { int cmp = arrayCollator.compare(p1.y.x, p2.y.x); if (cmp == 0) cmp = collator.compare(p1.y.y.getValue(Action.NAME), p2.y.y.getValue(Action.NAME)); return cmp; } }); result.addAll(sortedResult); addSearchFilterActions(result); addReportActions(result); getWorkspaceChooserController().addGenericActions(result); return result; }
From source file:com.jeans.iservlet.controller.impl.ExportController.java
/** * ???//w ww. j a v a 2 s .c om * * @return * @throws IOException */ @RequestMapping(method = RequestMethod.POST, value = "/systems") public ResponseEntity<byte[]> exportITSystems() throws IOException { StringBuilder fn = new StringBuilder(getCurrentCompany().getName()); fn.append(" - ??("); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet("?"); // ? // // ?10?? Font tFont = sheet.getWorkbook().createFont(); tFont.setBoldweight(Font.BOLDWEIGHT_BOLD); tFont.setFontName(""); tFont.setFontHeightInPoints((short) 10); // ????????? CellStyle cellStyleTitle = sheet.getWorkbook().createCellStyle(); cellStyleTitle.setAlignment(CellStyle.ALIGN_CENTER); cellStyleTitle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); cellStyleTitle.setFont(tFont); cellStyleTitle.setDataFormat(HSSFDataFormat.getBuiltinFormat("text")); cellStyleTitle.setWrapText(false); // 20 Row row = sheet.createRow(0); row.setHeightInPoints(20); Cell cell = null; for (int i = 0; i < ITSYSTEM_HEADERS.length; i++) { cell = row.createCell(i, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleTitle); cell.setCellValue(ITSYSTEM_HEADERS[i]); sheet.setColumnWidth(i, ITSYSTEM_HEADERS_WIDTH[i] * 256); } // ?????->?->???? List<ITSystem> systems = new ArrayList<ITSystem>(systService.listSystems(getCurrentCompany(), null, null)); Collections.sort(systems, new Comparator<ITSystem>() { @Override public int compare(ITSystem o1, ITSystem o2) { int ret = o1.getType().ordinal() - o2.getType().ordinal(); if (ret == 0) { ret = Long.compare(o1.getOwner().getId(), o2.getOwner().getId()); if (ret == 0) { ret = Collator.getInstance(java.util.Locale.CHINA).compare(o1.getName(), o2.getName()); } } return ret; } }); // ?? DataFormat df = sheet.getWorkbook().createDataFormat(); // ?10? Font font = sheet.getWorkbook().createFont(); font.setFontName(""); font.setFontHeightInPoints((short) 10); // ?1??????? CellStyle cellStyleString = sheet.getWorkbook().createCellStyle(); cellStyleString.setAlignment(CellStyle.ALIGN_CENTER); cellStyleString.setVerticalAlignment(CellStyle.VERTICAL_CENTER); cellStyleString.setFont(font); cellStyleString.setDataFormat(HSSFDataFormat.getBuiltinFormat("text")); cellStyleString.setWrapText(false); // ?2????(yyyyMMdd)??? CellStyle cellStyleDate = sheet.getWorkbook().createCellStyle(); cellStyleDate.setAlignment(CellStyle.ALIGN_CENTER); cellStyleDate.setVerticalAlignment(CellStyle.VERTICAL_CENTER); cellStyleDate.setFont(font); cellStyleDate.setDataFormat(df.getFormat("yyyyMMdd")); cellStyleDate.setWrapText(false); // ?3??????(#)??? CellStyle cellStyleQuantity = sheet.getWorkbook().createCellStyle(); cellStyleQuantity.setAlignment(CellStyle.ALIGN_CENTER); cellStyleQuantity.setVerticalAlignment(CellStyle.VERTICAL_CENTER); cellStyleQuantity.setFont(font); cellStyleQuantity.setDataFormat(df.getFormat("0")); cellStyleQuantity.setWrapText(false); // ?4?????(#,##0.00_ )??? CellStyle cellStyleCost = sheet.getWorkbook().createCellStyle(); cellStyleCost.setAlignment(CellStyle.ALIGN_RIGHT); cellStyleCost.setVerticalAlignment(CellStyle.VERTICAL_CENTER); cellStyleCost.setFont(font); cellStyleCost.setDataFormat(df.getFormat("#,##0.00_ ")); cellStyleCost.setWrapText(false); // sheet int rowNumber = 1; for (ITSystem system : systems) { // 20 row = sheet.createRow(rowNumber); row.setHeightInPoints(20); // ? Set<SystemBranch> branches = system.getBranches(); SystemBranch localBranch = null; // ?? long localId = 0; if (getCurrentCompany().getLevel() == Company.BRANCH) { localId = getCurrentCompany().getSuperior().getId(); } else { localId = getCurrentCompany().getId(); } BigDecimal cost = new BigDecimal("0.0"); // for (SystemBranch branch : branches) { cost.add(branch.getCost()); if (branch.getCompany().getId() == localId) { localBranch = branch; } } boolean branched = (localBranch != null); // ? boolean owned = system.getOwner().getId() == getCurrentCompany().getId(); // ????? // // cell = row.createCell(0, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getType().getTitle()); // ?? cell = row.createCell(1, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getName()); // cell = row.createCell(2, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getAlias()); // /? cell = row.createCell(3, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getModelOrVersion()); // cell = row.createCell(4, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getBrief()); // ? cell = row.createCell(5, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(ITSYSTEM_sLevel[system.getSecurityLevel()]); // ??? cell = row.createCell(6, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getSecurityCode()); // ? cell = row.createCell(7, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getUsersBrief()); // cell = row.createCell(8, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(null == system.getProvider() ? "" : system.getProvider().getAlias()); // ? cell = row.createCell(9, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getOwner().getAlias()); // cell = row.createCell(10, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getScope().getTitle(system.getOwner().getLevel())); // cell = row.createCell(11, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getDeploy().getTitle()); // cell = row.createCell(12, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(branched ? "" : ""); if (branched) { // ?() cell = row.createCell(13, Cell.CELL_TYPE_NUMERIC); cell.setCellStyle(cellStyleCost); cell.setCellValue(localBranch.getCost().doubleValue()); // ? cell = row.createCell(14, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(localBranch.getStage().getTitle()); // ? cell = row.createCell(15, Cell.CELL_TYPE_NUMERIC); cell.setCellStyle(cellStyleDate); Date ct = localBranch.getConstructedTime(); if (null != ct) { cell.setCellValue(ct); } // ? cell = row.createCell(16, Cell.CELL_TYPE_NUMERIC); cell.setCellStyle(cellStyleDate); Date at = localBranch.getAbandonedTime(); if (null != at) { cell.setCellValue(at); } } // ?? cell = row.createCell(17, Cell.CELL_TYPE_NUMERIC); cell.setCellStyle(cellStyleQuantity); cell.setCellValue(system.getFreeMaintainMonths()); if (owned) { // cell = row.createCell(18, Cell.CELL_TYPE_NUMERIC); cell.setCellStyle(cellStyleQuantity); cell.setCellValue(branches.size()); // ?) cell = row.createCell(19, Cell.CELL_TYPE_NUMERIC); cell.setCellStyle(cellStyleCost); cell.setCellValue(cost.doubleValue()); // ?? cell = row.createCell(20, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyleString); cell.setCellValue(system.getStage().getTitle()); // ? cell = row.createCell(21, Cell.CELL_TYPE_NUMERIC); cell.setCellStyle(cellStyleDate); Date ct = system.getConstructedTime(); if (null != ct) { cell.setCellValue(ct); } // ? cell = row.createCell(22, Cell.CELL_TYPE_NUMERIC); cell.setCellStyle(cellStyleDate); Date at = system.getAbandonedTime(); if (null != at) { cell.setCellValue(at); } } rowNumber++; } fn.append((new SimpleDateFormat("yyyyMMdd")).format(new Date())).append(").xlsx"); String filename = null; if (isIE()) { filename = URLEncoder.encode(fn.toString(), "UTF-8").replaceAll("\\+", "%20"); } else { filename = new String(fn.toString().getBytes("UTF-8"), "iso8859-1"); } response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-disposition", "attachment; filename=" + filename); BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream(), 4096); wb.write(out); wb.close(); out.close(); return null; }
From source file:org.apache.nifi.web.api.dto.DtoFactory.java
/** * Creates a ProcessorDTO from the specified ProcessorNode. * * @param node node/* w w w .j a va 2 s .c o m*/ * @return dto */ public ProcessorDTO createProcessorDto(final ProcessorNode node) { if (node == null) { return null; } final ProcessorDTO dto = new ProcessorDTO(); dto.setId(node.getIdentifier()); dto.setPosition(createPositionDto(node.getPosition())); dto.setStyle(node.getStyle()); dto.setParentGroupId(node.getProcessGroup().getIdentifier()); dto.setInputRequirement(node.getInputRequirement().name()); dto.setType(node.getProcessor().getClass().getCanonicalName()); dto.setName(node.getName()); dto.setState(node.getScheduledState().toString()); // build the relationship dtos final List<RelationshipDTO> relationships = new ArrayList<>(); for (final Relationship rel : node.getRelationships()) { final RelationshipDTO relationshipDTO = new RelationshipDTO(); relationshipDTO.setDescription(rel.getDescription()); relationshipDTO.setName(rel.getName()); relationshipDTO.setAutoTerminate(node.isAutoTerminated(rel)); relationships.add(relationshipDTO); } // sort the relationships Collections.sort(relationships, new Comparator<RelationshipDTO>() { @Override public int compare(RelationshipDTO r1, RelationshipDTO r2) { return Collator.getInstance(Locale.US).compare(r1.getName(), r2.getName()); } }); // set the relationships dto.setRelationships(relationships); dto.setDescription(getCapabilityDescription(node.getClass())); dto.setSupportsParallelProcessing(!node.isTriggeredSerially()); dto.setSupportsEventDriven(node.isEventDrivenSupported()); dto.setSupportsBatching(node.isHighThroughputSupported()); dto.setConfig(createProcessorConfigDto(node)); final Collection<ValidationResult> validationErrors = node.getValidationErrors(); if (validationErrors != null && !validationErrors.isEmpty()) { final List<String> errors = new ArrayList<>(); for (final ValidationResult validationResult : validationErrors) { errors.add(validationResult.toString()); } dto.setValidationErrors(errors); } return dto; }
From source file:org.apache.nifi.web.api.dto.DtoFactory.java
/** * Creates a ProcessorConfigDTO from the specified ProcessorNode. * * @param procNode node//from w ww .j a v a 2 s. c o m * @return dto */ public ProcessorConfigDTO createProcessorConfigDto(final ProcessorNode procNode) { if (procNode == null) { return null; } final ProcessorConfigDTO dto = new ProcessorConfigDTO(); // sort a copy of the properties final Map<PropertyDescriptor, String> sortedProperties = new TreeMap<>( new Comparator<PropertyDescriptor>() { @Override public int compare(PropertyDescriptor o1, PropertyDescriptor o2) { return Collator.getInstance(Locale.US).compare(o1.getName(), o2.getName()); } }); sortedProperties.putAll(procNode.getProperties()); // get the property order from the processor final Processor processor = procNode.getProcessor(); final Map<PropertyDescriptor, String> orderedProperties = new LinkedHashMap<>(); final List<PropertyDescriptor> descriptors = processor.getPropertyDescriptors(); if (descriptors != null && !descriptors.isEmpty()) { for (PropertyDescriptor descriptor : descriptors) { orderedProperties.put(descriptor, null); } } orderedProperties.putAll(sortedProperties); // build the descriptor and property dtos dto.setDescriptors(new LinkedHashMap<String, PropertyDescriptorDTO>()); dto.setProperties(new LinkedHashMap<String, String>()); for (final Map.Entry<PropertyDescriptor, String> entry : orderedProperties.entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); // store the property descriptor dto.getDescriptors().put(descriptor.getName(), createPropertyDescriptorDto(descriptor)); // determine the property value - don't include sensitive properties String propertyValue = entry.getValue(); if (propertyValue != null && descriptor.isSensitive()) { propertyValue = "********"; } // set the property value dto.getProperties().put(descriptor.getName(), propertyValue); } dto.setSchedulingPeriod(procNode.getSchedulingPeriod()); dto.setPenaltyDuration(procNode.getPenalizationPeriod()); dto.setYieldDuration(procNode.getYieldPeriod()); dto.setRunDurationMillis(procNode.getRunDuration(TimeUnit.MILLISECONDS)); dto.setConcurrentlySchedulableTaskCount(procNode.getMaxConcurrentTasks()); dto.setLossTolerant(procNode.isLossTolerant()); dto.setComments(procNode.getComments()); dto.setBulletinLevel(procNode.getBulletinLevel().name()); dto.setSchedulingStrategy(procNode.getSchedulingStrategy().name()); dto.setAnnotationData(procNode.getAnnotationData()); // set up the default values for concurrent tasks and scheduling period final Map<String, String> defaultConcurrentTasks = new HashMap<>(); defaultConcurrentTasks.put(SchedulingStrategy.TIMER_DRIVEN.name(), String.valueOf(SchedulingStrategy.TIMER_DRIVEN.getDefaultConcurrentTasks())); defaultConcurrentTasks.put(SchedulingStrategy.EVENT_DRIVEN.name(), String.valueOf(SchedulingStrategy.EVENT_DRIVEN.getDefaultConcurrentTasks())); defaultConcurrentTasks.put(SchedulingStrategy.CRON_DRIVEN.name(), String.valueOf(SchedulingStrategy.CRON_DRIVEN.getDefaultConcurrentTasks())); dto.setDefaultConcurrentTasks(defaultConcurrentTasks); final Map<String, String> defaultSchedulingPeriod = new HashMap<>(); defaultSchedulingPeriod.put(SchedulingStrategy.TIMER_DRIVEN.name(), SchedulingStrategy.TIMER_DRIVEN.getDefaultSchedulingPeriod()); defaultSchedulingPeriod.put(SchedulingStrategy.CRON_DRIVEN.name(), SchedulingStrategy.CRON_DRIVEN.getDefaultSchedulingPeriod()); dto.setDefaultSchedulingPeriod(defaultSchedulingPeriod); return dto; }
From source file:de.innovationgate.webgate.api.WGDatabase.java
private void reconfigureCore(boolean prepareOnly, WGUserAccess userAccess) throws WGAPIException { // Initialize data from core if (this.title == null) { this.title = this.core.getTitle(); }/*from w w w .j a v a 2s. com*/ this.typeName = this.core.getTypeName(); // Initialize CS roles List<?> roles = this.core.getRoles(); if (roles.contains(WGDatabase.ROLE_CONTENT)) { this.contentRole = true; } if (roles.contains(WGDatabase.ROLE_DESIGN)) { this.designRole = true; } if (roles.contains(WGDatabase.ROLE_REPOSITORY)) { this.repositoryRole = true; } if (roles.contains(WGDatabase.ROLE_USERPROFILES)) { this.userProfilesRole = true; } // Initialize max cores setting if (creationOptions.containsKey(COPTION_MAXCORES)) { try { maxCores = Integer.parseInt((String) creationOptions.get(COPTION_MAXCORES)); } catch (NumberFormatException e) { WGFactory.getLogger().error("Cannot interpret creation option " + COPTION_MAXCORES + " as an integer. Defaulting to " + maxCores); } if (maxCores == 0) { maxCores = Integer.MAX_VALUE; } } // Initialize background monitoring for database changes if (!prepareOnly) { this.monitorLastChange = this.core.hasFeature(FEATURE_LASTCHANGED); if (creationOptions.containsKey(COPTION_MONITORLASTCHANGE)) { monitorLastChange = Boolean.valueOf(String.valueOf(creationOptions.get(COPTION_MONITORLASTCHANGE))) .booleanValue(); } } // Initialize caching enablement if (creationOptions.containsKey(COPTION_CACHING_ENABLED)) { cachingEnabled = Boolean.valueOf(String.valueOf(creationOptions.get(COPTION_CACHING_ENABLED))) .booleanValue(); } // Initialize cache maintenance if (creationOptions.containsKey(COPTION_ALLOWCACHEMAINTENANCE)) { allowCacheMaintenance = Boolean .valueOf(String.valueOf(creationOptions.get(COPTION_ALLOWCACHEMAINTENANCE))).booleanValue(); } // Online deletion check for documents if (creationOptions.containsKey(COPTION_DELETIONCHECK)) { deletionCheck = Boolean.valueOf(String.valueOf(creationOptions.get(COPTION_DELETIONCHECK))) .booleanValue(); } // Project mode if (creationOptions.containsKey(COPTION_PROJECTMODE)) { projectMode = Boolean.valueOf(String.valueOf(creationOptions.get(COPTION_PROJECTMODE))).booleanValue(); WGFactory.getLogger().info("Enabled project mode for database " + getDbReference()); } // Initialize reader profile creation if (creationOptions.containsKey(COPTION_READERPROFILECREATION)) { readerProfileCreation = Boolean .valueOf(String.valueOf(creationOptions.get(COPTION_READERPROFILECREATION))).booleanValue(); } // Initialize page rights filter if (creationOptions.containsKey(COPTION_PAGERIGHTSFILTER)) { String filterName = (String) creationOptions.get(COPTION_PAGERIGHTSFILTER); try { @SuppressWarnings("unchecked") Class<? extends PageRightsFilter> filterClass = (Class<? extends PageRightsFilter>) WGFactory .getImplementationLoader().loadClass(filterName); PageRightsFilter filter = filterClass.newInstance(); _pageRightsFilter = filter; } catch (Exception e) { throw new WGIllegalArgumentException("Exception instantiating page rights filter: " + filterName, e); } } onConnect(new DatabaseAction() { @Override public void run(WGDatabase db) throws Exception { getPageRightsFilter().init(db); } }); if (creationOptions.containsKey(COPTION_AUTOAPPROVE)) { autoApprove = Boolean.valueOf(String.valueOf(creationOptions.get(COPTION_AUTOAPPROVE))).booleanValue(); } pageReadersEnabled = this.core.hasFeature(FEATURE_FULLCONTENTFEATURES) && this.core.getContentStoreVersion() >= WGDatabase.CSVERSION_WGA5; if (creationOptions.containsKey(COPTION_PAGEREADERS_ENABLED)) { pageReadersEnabled = Boolean.valueOf(String.valueOf(creationOptions.get(COPTION_PAGEREADERS_ENABLED))) .booleanValue(); } if (creationOptions.containsKey(COPTION_USERCACHES_ENABLED)) { userCachesEnabled = Boolean.valueOf(String.valueOf(creationOptions.get(COPTION_USERCACHES_ENABLED))) .booleanValue(); } // Initialize update timeout for background changes if (creationOptions.containsKey(COPTION_UPDATETIMEOUT)) { try { updateTimeoutSeconds = Integer.parseInt((String) creationOptions.get(COPTION_UPDATETIMEOUT)); WGFactory.getLogger().info("Update timeout is set to " + updateTimeoutSeconds + " seconds."); } catch (NumberFormatException e) { WGFactory.getLogger().error("Cannot parse db option " + COPTION_UPDATETIMEOUT + " value " + creationOptions.get(COPTION_UPDATETIMEOUT)); } } // Initialize user cache latency if (creationOptions.containsKey(COPTION_USERCACHELATENCY)) { String latencyStr = (String) creationOptions.get(COPTION_USERCACHELATENCY); try { userCacheLatency = Integer.parseInt(latencyStr); } catch (NumberFormatException e) { WGFactory.getLogger().error("Cannot parse db option " + COPTION_USERCACHELATENCY + " value " + creationOptions.get(COPTION_USERCACHELATENCY)); } } // Initialize other caches latency _cacheLatency = 0; if (!hasFeature(FEATURE_FIND_UPDATED_DOCS)) { _cacheLatency = CACHELATENCY_DEFAULT_NOT_UPDATEABLE_DBS; } if (creationOptions.containsKey(COPTION_CACHELATENCY)) { String latencyStr = (String) creationOptions.get(COPTION_CACHELATENCY); try { _cacheLatency = Integer.parseInt(latencyStr); } catch (NumberFormatException e) { WGFactory.getLogger().error("Cannot parse db option " + COPTION_CACHELATENCY + " value " + creationOptions.get(COPTION_CACHELATENCY)); } } // Setup user hashmaps if (!hasFeature(FEATURE_CONTENT_READ_PROTECTION)) { this.userHashMapGroup.setSingleUserMode(true); } else if (userCacheLatency != 0) { _userCache.setMapLatency(userCacheLatency * 1000 * 60); } // Initialize list cache rebuild threshold if (creationOptions.containsKey(COPTION_LIST_CACHE_REBUILD_THRESHOLD)) { String thresholdStr = (String) creationOptions.get(COPTION_LIST_CACHE_REBUILD_THRESHOLD); try { listCacheRebuildThreshold = Integer.parseInt(thresholdStr); WGFactory.getLogger() .info("User list cache rebuild threshold is set to " + listCacheRebuildThreshold); } catch (NumberFormatException e) { WGFactory.getLogger().error("Cannot parse db option " + COPTION_LIST_CACHE_REBUILD_THRESHOLD + " value " + thresholdStr); } } // Init mandatory readers if (creationOptions.containsKey(COPTION_MANDATORY_READERS)) { try { _mandatoryReaders = (List<String>) JSONListOptionType.INSTANCE .unconvert((String) creationOptions.get(COPTION_MANDATORY_READERS)); } catch (OptionConversionException e) { WGFactory.getLogger().error("Cannot parse db option " + COPTION_MANDATORY_READERS + " value " + creationOptions.get(COPTION_MANDATORY_READERS)); } } // Init content store version _csVersion = this.core.getContentStoreVersion(); _csPatchLevel = this.core.getContentStorePatchLevel(); // Init last modified date updateRevision(WGDatabaseRevision.forValue(this.core.getRevision())); // Init value of nonexistent items noItemBehaviour = new NoItemBehaviour(); if (creationOptions.containsKey(COPTION_NOITEMBEHAVIOUR)) { String noItemValueProp = (String) creationOptions.get(COPTION_NOITEMBEHAVIOUR); if (noItemValueProp.equalsIgnoreCase("compatible")) { noItemBehaviour.compatibleForDBImplementation(core); } } // If the db should only get prepared, close the core again if (prepareOnly) { core.close(); // core = null; Not safe. Many processes rely on an existing core connected = false; } // Else open a master session else { // Open a session context WGSessionContext sessionContext = new WGSessionContext(this, MasterLoginAuthSession.getInstance(), null, userAccess, null); this.setSessionContext(sessionContext); // Initialize default language collator try { _defaultLanguageCollator = Collator .getInstance(WGLanguage.languageNameToLocale(getDefaultLanguage())); } catch (Exception e) { WGFactory.getLogger() .error("Error determining default language collator. Using default platform collator", e); _defaultLanguageCollator = Collator.getInstance(); } // Initialize custom workflow engine initWorkflowEngine(); // Set database UUID if not yet present if (getContentStoreVersion() >= WGDatabase.CSVERSION_WGA5 && !getTypeName().equals(WGFakeDatabase.DBTYPE)) { _uuid = (String) getExtensionData(EXTDATA_DATABASE_UUID); if (_uuid == null) { _uuid = UUID.randomUUID().toString(); writeExtensionData(EXTDATA_DATABASE_UUID, _uuid); } } connected = true; } }
From source file:org.alfresco.repo.search.impl.lucene.ADMLuceneTest.java
/** * @throws Exception/* w w w . ja v a 2s .c om*/ */ public void testSort() throws Exception { Collator collator = Collator.getInstance(I18NUtil.getLocale()); luceneFTS.pause(); buildBaseIndex(); runBaseTests(); ADMLuceneSearcherImpl searcher = buildSearcher(); SearchParameters sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage(SearchService.LANGUAGE_LUCENE); sp.setQuery("PATH:\"//.\""); sp.addSort("ID", true); ResultSet results = searcher.query(sp); String current = null; for (ResultSetRow row : results) { String id = row.getNodeRef().getId(); if (current != null) { if (collator.compare(current, id) > 0) { fail(); } } current = id; } results.close(); SearchParameters sp2 = new SearchParameters(); sp2.addStore(rootNodeRef.getStoreRef()); sp2.setLanguage(SearchService.LANGUAGE_LUCENE); sp2.setQuery("PATH:\"//.\""); sp2.addSort("ID", false); results = searcher.query(sp2); current = null; for (ResultSetRow row : results) { String id = row.getNodeRef().getId(); if (current != null) { if (collator.compare(current, id) < 0) { fail(); } } current = id; } results.close(); luceneFTS.resume(); SearchParameters sp3 = new SearchParameters(); sp3.addStore(rootNodeRef.getStoreRef()); sp3.setLanguage(SearchService.LANGUAGE_LUCENE); sp3.setQuery("PATH:\"//.\""); sp3.addSort(SearchParameters.SORT_IN_DOCUMENT_ORDER_ASCENDING); results = searcher.query(sp3); int count = 0; for (ResultSetRow row : results) { assertEquals(documentOrder[count++], row.getNodeRef()); } results.close(); SearchParameters sp4 = new SearchParameters(); sp4.addStore(rootNodeRef.getStoreRef()); sp4.setLanguage(SearchService.LANGUAGE_LUCENE); sp4.setQuery("PATH:\"//.\""); sp4.addSort(SearchParameters.SORT_IN_DOCUMENT_ORDER_DESCENDING); results = searcher.query(sp4); count = 1; for (ResultSetRow row : results) { assertEquals(documentOrder[documentOrder.length - (count++)], row.getNodeRef()); } results.close(); SearchParameters sp5 = new SearchParameters(); sp5.addStore(rootNodeRef.getStoreRef()); sp5.setLanguage(SearchService.LANGUAGE_LUCENE); sp5.setQuery("PATH:\"//.\""); sp5.addSort(SearchParameters.SORT_IN_SCORE_ORDER_ASCENDING); results = searcher.query(sp5); float score = 0; for (ResultSetRow row : results) { assertTrue(score <= row.getScore()); score = row.getScore(); } results.close(); SearchParameters sp6 = new SearchParameters(); sp6.addStore(rootNodeRef.getStoreRef()); sp6.setLanguage(SearchService.LANGUAGE_LUCENE); sp6.setQuery("PATH:\"//.\""); sp6.addSort(SearchParameters.SORT_IN_SCORE_ORDER_DESCENDING); results = searcher.query(sp6); score = 1.0f; for (ResultSetRow row : results) { assertTrue(score >= row.getScore()); score = row.getScore(); } results.close(); // sort by created date SearchParameters sp7 = new SearchParameters(); sp7.addStore(rootNodeRef.getStoreRef()); sp7.setLanguage(SearchService.LANGUAGE_LUCENE); sp7.setQuery("PATH:\"//.\""); sp7.addSort("@" + createdDate.getPrefixedQName(namespacePrefixResolver), true); results = searcher.query(sp7); Date date = null; for (ResultSetRow row : results) { Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class, nodeService.getProperty(row.getNodeRef(), createdDate)); // System.out.println(currentBun); if (date != null) { assertTrue(date.compareTo(currentBun) <= 0); } date = currentBun; } results.close(); SearchParameters sp8 = new SearchParameters(); sp8.addStore(rootNodeRef.getStoreRef()); sp8.setLanguage(SearchService.LANGUAGE_LUCENE); sp8.setQuery("PATH:\"//.\""); sp8.addSort("@" + createdDate, false); results = searcher.query(sp8); date = null; for (ResultSetRow row : results) { Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class, nodeService.getProperty(row.getNodeRef(), createdDate)); // System.out.println(currentBun); if ((date != null) && (currentBun != null)) { assertTrue(date.compareTo(currentBun) >= 0); } date = currentBun; } results.close(); SearchParameters sp_7 = new SearchParameters(); sp_7.addStore(rootNodeRef.getStoreRef()); sp_7.setLanguage(SearchService.LANGUAGE_LUCENE); sp_7.setQuery("PATH:\"//.\""); sp_7.addSort("@" + ContentModel.PROP_MODIFIED, true); results = searcher.query(sp_7); date = null; for (ResultSetRow row : results) { Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class, nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_MODIFIED)); if (currentBun != null) { Calendar c = new GregorianCalendar(); c.setTime(currentBun); c.set(Calendar.MILLISECOND, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.HOUR_OF_DAY, 0); currentBun = c.getTime(); } if ((date != null) && (currentBun != null)) { assertTrue(date.compareTo(currentBun) <= 0); } date = currentBun; } results.close(); SearchParameters sp_8 = new SearchParameters(); sp_8.addStore(rootNodeRef.getStoreRef()); sp_8.setLanguage(SearchService.LANGUAGE_LUCENE); sp_8.setQuery("PATH:\"//.\""); sp_8.addSort("@" + ContentModel.PROP_MODIFIED, false); results = searcher.query(sp_8); date = null; for (ResultSetRow row : results) { Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class, nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_MODIFIED)); // System.out.println(currentBun); if (currentBun != null) { Calendar c = new GregorianCalendar(); c.setTime(currentBun); c.set(Calendar.MILLISECOND, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.HOUR_OF_DAY, 0); currentBun = c.getTime(); } if ((date != null) && (currentBun != null)) { assertTrue(date.compareTo(currentBun) >= 0); } date = currentBun; } results.close(); // sort by double SearchParameters sp9 = new SearchParameters(); sp9.addStore(rootNodeRef.getStoreRef()); sp9.setLanguage(SearchService.LANGUAGE_LUCENE); sp9.setQuery("PATH:\"//.\""); sp9.addSort("@" + orderDouble, true); results = searcher.query(sp9); Double d = null; for (ResultSetRow row : results) { Double currentBun = DefaultTypeConverter.INSTANCE.convert(Double.class, nodeService.getProperty(row.getNodeRef(), orderDouble)); // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun); if (d != null) { assertTrue(d.compareTo(currentBun) <= 0); } d = currentBun; } results.close(); SearchParameters sp10 = new SearchParameters(); sp10.addStore(rootNodeRef.getStoreRef()); sp10.setLanguage(SearchService.LANGUAGE_LUCENE); sp10.setQuery("PATH:\"//.\""); sp10.addSort("@" + orderDouble, false); results = searcher.query(sp10); d = null; for (ResultSetRow row : results) { Double currentBun = DefaultTypeConverter.INSTANCE.convert(Double.class, nodeService.getProperty(row.getNodeRef(), orderDouble)); // System.out.println(currentBun); if ((d != null) && (currentBun != null)) { assertTrue(d.compareTo(currentBun) >= 0); } d = currentBun; } results.close(); // sort by float SearchParameters sp11 = new SearchParameters(); sp11.addStore(rootNodeRef.getStoreRef()); sp11.setLanguage(SearchService.LANGUAGE_LUCENE); sp11.setQuery("PATH:\"//.\""); sp11.addSort("@" + orderFloat, true); results = searcher.query(sp11); Float f = null; for (ResultSetRow row : results) { Float currentBun = DefaultTypeConverter.INSTANCE.convert(Float.class, nodeService.getProperty(row.getNodeRef(), orderFloat)); // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun); if (f != null) { assertTrue(f.compareTo(currentBun) <= 0); } f = currentBun; } results.close(); SearchParameters sp12 = new SearchParameters(); sp12.addStore(rootNodeRef.getStoreRef()); sp12.setLanguage(SearchService.LANGUAGE_LUCENE); sp12.setQuery("PATH:\"//.\""); sp12.addSort("@" + orderFloat, false); results = searcher.query(sp12); f = null; for (ResultSetRow row : results) { Float currentBun = DefaultTypeConverter.INSTANCE.convert(Float.class, nodeService.getProperty(row.getNodeRef(), orderFloat)); // System.out.println(currentBun); if ((f != null) && (currentBun != null)) { assertTrue(f.compareTo(currentBun) >= 0); } f = currentBun; } results.close(); // sort by long SearchParameters sp13 = new SearchParameters(); sp13.addStore(rootNodeRef.getStoreRef()); sp13.setLanguage(SearchService.LANGUAGE_LUCENE); sp13.setQuery("PATH:\"//.\""); sp13.addSort("@" + orderLong, true); results = searcher.query(sp13); Long l = null; for (ResultSetRow row : results) { Long currentBun = DefaultTypeConverter.INSTANCE.convert(Long.class, nodeService.getProperty(row.getNodeRef(), orderLong)); // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun); if (l != null) { assertTrue(l.compareTo(currentBun) <= 0); } l = currentBun; } results.close(); SearchParameters sp14 = new SearchParameters(); sp14.addStore(rootNodeRef.getStoreRef()); sp14.setLanguage(SearchService.LANGUAGE_LUCENE); sp14.setQuery("PATH:\"//.\""); sp14.addSort("@" + orderLong, false); results = searcher.query(sp14); l = null; for (ResultSetRow row : results) { Long currentBun = DefaultTypeConverter.INSTANCE.convert(Long.class, nodeService.getProperty(row.getNodeRef(), orderLong)); // System.out.println(currentBun); if ((l != null) && (currentBun != null)) { assertTrue(l.compareTo(currentBun) >= 0); } l = currentBun; } results.close(); // sort by int SearchParameters sp15 = new SearchParameters(); sp15.addStore(rootNodeRef.getStoreRef()); sp15.setLanguage(SearchService.LANGUAGE_LUCENE); sp15.setQuery("PATH:\"//.\""); sp15.addSort("@" + orderInt, true); results = searcher.query(sp15); Integer i = null; for (ResultSetRow row : results) { Integer currentBun = DefaultTypeConverter.INSTANCE.convert(Integer.class, nodeService.getProperty(row.getNodeRef(), orderInt)); // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun); if (i != null) { assertTrue(i.compareTo(currentBun) <= 0); } i = currentBun; } results.close(); SearchParameters sp16 = new SearchParameters(); sp16.addStore(rootNodeRef.getStoreRef()); sp16.setLanguage(SearchService.LANGUAGE_LUCENE); sp16.setQuery("PATH:\"//.\""); sp16.addSort("@" + orderInt, false); results = searcher.query(sp16); i = null; for (ResultSetRow row : results) { Integer currentBun = DefaultTypeConverter.INSTANCE.convert(Integer.class, nodeService.getProperty(row.getNodeRef(), orderInt)); // System.out.println(currentBun); if ((i != null) && (currentBun != null)) { assertTrue(i.compareTo(currentBun) >= 0); } i = currentBun; } results.close(); // sort by text SearchParameters sp17 = new SearchParameters(); sp17.addStore(rootNodeRef.getStoreRef()); sp17.setLanguage(SearchService.LANGUAGE_LUCENE); sp17.setQuery("PATH:\"//.\""); sp17.addSort("@" + orderText, true); results = searcher.query(sp17); String text = null; for (ResultSetRow row : results) { String currentBun = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(row.getNodeRef(), orderText)); // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun); if ((text != null) && (currentBun != null)) { assertTrue(collator.compare(text, currentBun) <= 0); } text = currentBun; } results.close(); SearchParameters sp18 = new SearchParameters(); sp18.addStore(rootNodeRef.getStoreRef()); sp18.setLanguage(SearchService.LANGUAGE_LUCENE); sp18.setQuery("PATH:\"//.\""); sp18.addSort("@" + orderText, false); results = searcher.query(sp18); text = null; for (ResultSetRow row : results) { String currentBun = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(row.getNodeRef(), orderText)); // System.out.println(currentBun); if ((text != null) && (currentBun != null)) { assertTrue(collator.compare(text, currentBun) >= 0); } text = currentBun; } results.close(); // sort by content size // sort by ML text // Locale[] testLocales = new Locale[] { I18NUtil.getLocale(), Locale.ENGLISH, Locale.FRENCH, Locale.CHINESE }; Locale[] testLocales = new Locale[] { I18NUtil.getLocale(), Locale.ENGLISH, Locale.FRENCH }; for (Locale testLocale : testLocales) { Collator localisedCollator = Collator.getInstance(testLocale); SearchParameters sp19 = new SearchParameters(); sp19.addStore(rootNodeRef.getStoreRef()); sp19.setLanguage(SearchService.LANGUAGE_LUCENE); sp19.setQuery("PATH:\"//.\""); sp19.addSort("@" + orderMLText, true); sp19.addLocale(testLocale); results = searcher.query(sp19); text = null; for (ResultSetRow row : results) { MLText mltext = DefaultTypeConverter.INSTANCE.convert(MLText.class, nodeService.getProperty(row.getNodeRef(), orderMLText)); if (mltext != null) { String currentBun = mltext.getValue(testLocale); // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " // "+currentBun); if ((text != null) && (currentBun != null)) { assertTrue(localisedCollator.compare(text, currentBun) <= 0); } text = currentBun; } } results.close(); SearchParameters sp20 = new SearchParameters(); sp20.addStore(rootNodeRef.getStoreRef()); sp20.setLanguage(SearchService.LANGUAGE_LUCENE); sp20.setQuery("PATH:\"//.\""); sp20.addSort("@" + orderMLText, false); sp20.addLocale(testLocale); results = searcher.query(sp20); text = null; for (ResultSetRow row : results) { MLText mltext = DefaultTypeConverter.INSTANCE.convert(MLText.class, nodeService.getProperty(row.getNodeRef(), orderMLText)); if (mltext != null) { String currentBun = mltext.getValue(testLocale); if ((text != null) && (currentBun != null)) { assertTrue(localisedCollator.compare(text, currentBun) >= 0); } text = currentBun; } } results.close(); } luceneFTS.resume(); SearchParameters spN = new SearchParameters(); spN.addStore(rootNodeRef.getStoreRef()); spN.setLanguage(SearchService.LANGUAGE_LUCENE); spN.setQuery("PATH:\"//.\""); spN.addSort("cabbage", false); results = searcher.query(spN); results.close(); // test sort on unkown properties ALF-4193 spN = new SearchParameters(); spN.addStore(rootNodeRef.getStoreRef()); spN.setLanguage(SearchService.LANGUAGE_LUCENE); spN.setQuery("PATH:\"//.\""); spN.addSort("PARENT", false); results = searcher.query(spN); results.close(); spN = new SearchParameters(); spN.addStore(rootNodeRef.getStoreRef()); spN.setLanguage(SearchService.LANGUAGE_LUCENE); spN.setQuery("PATH:\"//.\""); spN.addSort("@PARENT:PARENT", false); results = searcher.query(spN); results.close(); luceneFTS.resume(); // sort by content size SearchParameters sp20 = new SearchParameters(); sp20.addStore(rootNodeRef.getStoreRef()); sp20.setLanguage(SearchService.LANGUAGE_LUCENE); sp20.setQuery("PATH:\"//.\""); sp20.addSort("@" + ContentModel.PROP_CONTENT + ".size", false); results = searcher.query(sp20); Long size = null; for (ResultSetRow row : results) { ContentData currentBun = DefaultTypeConverter.INSTANCE.convert(ContentData.class, nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_CONTENT)); // System.out.println(currentBun); if ((size != null) && (currentBun != null)) { assertTrue(size.compareTo(currentBun.getSize()) >= 0); } if (currentBun != null) { size = currentBun.getSize(); } } results.close(); // sort by content mimetype SearchParameters sp21 = new SearchParameters(); sp21.addStore(rootNodeRef.getStoreRef()); sp21.setLanguage(SearchService.LANGUAGE_LUCENE); sp21.setQuery("PATH:\"//.\""); sp21.addSort("@" + ContentModel.PROP_CONTENT + ".mimetype", false); results = searcher.query(sp21); String mimetype = null; for (ResultSetRow row : results) { ContentData currentBun = DefaultTypeConverter.INSTANCE.convert(ContentData.class, nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_CONTENT)); // System.out.println(currentBun); if ((mimetype != null) && (currentBun != null)) { assertTrue(mimetype.compareTo(currentBun.getMimetype()) >= 0); } if (currentBun != null) { mimetype = currentBun.getMimetype(); } } results.close(); }
From source file:de.innovationgate.webgate.api.WGDatabase.java
protected Collator getDefaultLanguageCollator() { if (_defaultLanguageCollator == null) { try {// w w w .j a v a2 s .c o m _defaultLanguageCollator = Collator .getInstance(WGLanguage.languageNameToLocale(getDefaultLanguage())); } catch (Exception e) { WGFactory.getLogger() .error("Error determining default language collator. Using default platform collator", e); _defaultLanguageCollator = Collator.getInstance(); } } return _defaultLanguageCollator; }
From source file:de.innovationgate.webgate.api.WGDatabase.java
/** * Manually set a default language for this database * /* w w w .ja v a 2 s .c o m*/ * @param defaultLanguage * The default language */ public void setDefaultLanguage(String defaultLanguage) { _defaultLanguage = defaultLanguage; _defaultLanguageCollator = Collator.getInstance(WGLanguage.languageNameToLocale(_defaultLanguage)); }