List of usage examples for java.util SortedSet size
int size();
From source file:net.sourceforge.seqware.common.metadata.MetadataWS.java
/** * {@inheritDoc}/*www . j a v a2 s . c o m*/ */ @Override public String listInstalledWorkflowParams(String workflowAccession) { StringBuffer sb = new StringBuffer(); try { Workflow workflow = ll.findWorkflowParams(workflowAccession); for (WorkflowParam wp : workflow.getWorkflowParams()) { sb.append("#key=" + wp.getKey() + ":type=" + wp.getType() + ":display="); if (wp.getDisplay()) { sb.append("T"); } else { sb.append("F"); } if (wp.getDisplayName() != null && wp.getDisplayName().length() > 0) { sb.append(":display_name=" + wp.getDisplayName()); } if (wp.getFileMetaType() != null && wp.getFileMetaType().length() > 0) { sb.append(":file_meta_type=" + wp.getFileMetaType()); } SortedSet<WorkflowParamValue> wpvalues = wp.getValues(); if (wpvalues != null && wpvalues.size() > 0) { sb.append(":pulldown_items="); boolean first = true; for (WorkflowParamValue wpv : wpvalues) { if (first) { first = false; sb.append(wpv.getDisplayName() + "|" + wpv.getValue()); } else { sb.append(";" + wpv.getDisplayName() + "|" + wpv.getValue()); } } } sb.append("\n"); if (wp.getDefaultValue() == null) { sb.append(wp.getKey() + "=" + "\n"); } else { sb.append(wp.getKey() + "=" + wp.getDefaultValue() + "\n"); } } } catch (IOException ex) { ex.printStackTrace(); } catch (JAXBException ex) { ex.printStackTrace(); } return (sb.toString()); }
From source file:org.wrml.runtime.schema.generator.SchemaGenerator.java
/** * Generate a {@link JavaBytecodeClass} from the specified {@link Schema}. * <p/>//from ww w.ja v a2 s .c o m * Like a *big* regex (regular expression), we can compile all of the * WRML schema metadata (as if it is a single *big* String input) into a * loaded Java class so that the rest of the WRML *runtime* can use * (Prototype-optimized) reflection to access WRML's type system. * * @param schema The Schema to represent as a Java class. * @return The Java class representation of the specified schema. */ public JavaBytecodeClass generateSchemaInterface(final Schema schema) { /* * Create the simple POJO that will return the transformation * information. By the end of this method, this will be full of Java * bytecode-oriented information gleaned from this method's schema * parameter. */ final JavaBytecodeClass javaBytecodeClass = new JavaBytecodeClass(); final JavaBytecodeAnnotation wrmlAnnotation = new JavaBytecodeAnnotation( SchemaGenerator.ANNOTATION_INTERNAL_NAME_WRML); wrmlAnnotation.setAttributeValue(AnnotationParameterName.uniqueName.name(), schema.getUniqueName().getFullName()); javaBytecodeClass.getAnnotations().add(wrmlAnnotation); final SortedSet<String> keySlotNameSet = new TreeSet<>(); /* * If the schema declares any key slots, note them with a * class-level annotation. */ final List<String> keySlotNames = schema.getKeySlotNames(); if (keySlotNames != null && keySlotNames.size() > 0) { keySlotNameSet.addAll(keySlotNames); } if (!keySlotNameSet.isEmpty()) { final String[] keySlotNamesArray = new String[keySlotNameSet.size()]; wrmlAnnotation.setAttributeValue(AnnotationParameterName.keySlotNames.name(), keySlotNameSet.toArray(keySlotNamesArray)); } /* * If the schema declares any comparable slots, note them with a * class-level annotation. */ final List<String> comparableSlotNames = schema.getComparableSlotNames(); if (comparableSlotNames != null && comparableSlotNames.size() > 0) { final String[] comparableSlotNamesArray = new String[comparableSlotNames.size()]; wrmlAnnotation.setAttributeValue(AnnotationParameterName.comparableSlotNames.name(), comparableSlotNames.toArray(comparableSlotNamesArray)); } wrmlAnnotation.setAttributeValue(AnnotationParameterName.titleSlotName.name(), schema.getTitleSlotName()); /* * In Java, all interfaces extend java.lang.Object, so this can * remain constant for Schema too. */ javaBytecodeClass.setSuperName(SchemaGenerator.OBJECT_INTERNAL_NAME); /* * Go from schema id (URI) to internal Java class name. This is a * simple matter of stripping the leading forward slash from the * URI's path. Internally (in the bytecode), Java's class names use * forward slash (/) instead of full stop dots (.). */ final URI schemaUri = schema.getUri(); final String interfaceInternalName = uriToInternalTypeName(schemaUri); // if (schema.getUniqueName() == null) // { // schema.setUniqueName(new UniqueName(schemaUri.getPath())); // } javaBytecodeClass.setInternalName(interfaceInternalName); /* * Add the class-level Description annotation to capture the * schema's description. */ final String schemaDescription = schema.getDescription(); if (schemaDescription != null && !schemaDescription.trim().isEmpty()) { final JavaBytecodeAnnotation schemaDescriptionAnnotation = new JavaBytecodeAnnotation( SchemaGenerator.ANNOTATION_INTERNAL_NAME_DESCRIPTION); schemaDescriptionAnnotation.setAttributeValue(AnnotationParameterName.value.name(), schemaDescription); javaBytecodeClass.getAnnotations().add(schemaDescriptionAnnotation); } String schemaTitle = schema.getTitle(); if (schemaTitle == null || schemaTitle.trim().isEmpty()) { schemaTitle = schema.getUniqueName().getLocalName(); } final JavaBytecodeAnnotation schemaTitleAnnotation = new JavaBytecodeAnnotation( SchemaGenerator.ANNOTATION_INTERNAL_NAME_TITLE); schemaTitleAnnotation.setAttributeValue(AnnotationParameterName.value.name(), schemaTitle); javaBytecodeClass.getAnnotations().add(schemaTitleAnnotation); final URI schemaThumbnailImageLocation = schema.getThumbnailLocation(); if (schemaThumbnailImageLocation != null) { final JavaBytecodeAnnotation schemaThumbnailImageAnnotation = new JavaBytecodeAnnotation( SchemaGenerator.ANNOTATION_INTERNAL_NAME_THUMBNAIL_IMAGE); schemaThumbnailImageAnnotation.setAttributeValue(AnnotationParameterName.value.name(), schemaThumbnailImageLocation.toString()); javaBytecodeClass.getAnnotations().add(schemaThumbnailImageAnnotation); } boolean isAggregate = false; /* * Turn the schema's base schema list into our Java class's base * (aka extended) interfaces. */ final List<URI> baseSchemaUris = schema.getBaseSchemaUris(); for (final URI baseSchemaUri : baseSchemaUris) { final String baseSchemaInternalName = uriToInternalTypeName(baseSchemaUri); javaBytecodeClass.getInterfaces().add(baseSchemaInternalName); if (!isAggregate && getSchemaLoader().getAggregateDocumentSchemaUri().equals(baseSchemaUri)) { isAggregate = true; final List<Slot> slots = schema.getSlots(); for (final Slot slot : slots) { final Value value = slot.getValue(); if (!(value instanceof LinkValue || value instanceof ModelValue || value instanceof MultiSelectValue)) { keySlotNameSet.add(slot.getName()); } } } } // Add the Model base interface javaBytecodeClass.getInterfaces().add(SchemaGenerator.MODEL_INTERFACE_INTERNAL_NAME); /* * Add the class-level Tags annotation to capture the schema's tags. */ final List<String> schemaTags = schema.getTags(); if (schemaTags != null && schemaTags.size() > 0) { final JavaBytecodeAnnotation tagsAnnotation = new JavaBytecodeAnnotation( SchemaGenerator.ANNOTATION_INTERNAL_NAME_TAGS); final String[] tagsArray = new String[schemaTags.size()]; tagsAnnotation.setAttributeValue(AnnotationParameterName.value.name(), schemaTags.toArray(tagsArray)); javaBytecodeClass.getAnnotations().add(tagsAnnotation); } final Long schemaVersion = schema.getVersion(); if (schemaVersion != null) { final JavaBytecodeAnnotation versionAnnotation = new JavaBytecodeAnnotation( SchemaGenerator.ANNOTATION_INTERNAL_NAME_VERSION); versionAnnotation.setAttributeValue(AnnotationParameterName.value.name(), schemaVersion); javaBytecodeClass.getAnnotations().add(versionAnnotation); } final Boolean maybeReadOnly = schema.isReadOnly(); if (maybeReadOnly != null && maybeReadOnly) { final JavaBytecodeAnnotation readOnlyAnnotation = new JavaBytecodeAnnotation( SchemaGenerator.ANNOTATION_INTERNAL_NAME_READ_ONLY); javaBytecodeClass.getAnnotations().add(readOnlyAnnotation); } /* * Generate the interface method signatures. */ generateSchemaInterfaceMethods(schema, javaBytecodeClass, isAggregate); // TODO: "Open slots" with signatures. Track the open slots via // the JavaBytecode types. // // TODO: The signature will need to be changed for generics: // Example: // // Java: public interface Test<T extends List<?>> extends List<T> // Class File: public abstract interface org.wrml.schema.Test // extends java.util.List // Signature: // <T::Ljava/util/List<*>;>Ljava/lang/Object;Ljava/util/List<TT;>; // javaBytecodeClass.setSignature(null); generateSchemaInterfaceBytecode(javaBytecodeClass); return javaBytecodeClass; }
From source file:ubc.pavlab.gotrack.beans.TrackView.java
/** * @param fromPanel Fetch data then create timeline from panel or not (from dialog) *///from w w w .j av a2 s . c om private void fetchTimeline(boolean fromPanel) { // TODO Currently we only select the first found evidence for each group to display, there might be more Collection<GeneOntologyTerm> selected = fromPanel ? selectedTerms : itemSelectViewTerms; Map<Edition, Map<GeneOntologyTerm, Set<EvidenceReference>>> allCombinedDirectSeries = goChartMap .get(new GraphTypeKey(GraphType.annotation, false, false)).get(COMBINED_TITLE); Map<GeneOntologyTerm, CustomTimelineModel<GeneOntologyTerm>> timelineMap = new HashMap<>(); Map<GeneOntologyTerm, Set<String>> timelineGroups = new HashMap<>(); for (GeneOntologyTerm term : selected) { CustomTimelineModel<GeneOntologyTerm> model = new CustomTimelineModel<>(term); timelineMap.put(term, model); timelineGroups.put(term, new HashSet<String>()); } for (Entry<Edition, Map<GeneOntologyTerm, Set<EvidenceReference>>> editionEntry : allCombinedDirectSeries .entrySet()) { for (GeneOntologyTerm term : selected) { Set<EvidenceReference> evs = editionEntry.getValue().get(term); Set<String> grp = timelineGroups.get(term); if (evs != null) { for (EvidenceReference ev : evs) { grp.add(ev.getCategory()); } } } } SortedSet<Edition> editions = new TreeSet<Edition>(allCombinedDirectSeries.keySet()); Edition currentEdition = null; for (Edition nextEdition : editions) { if (currentEdition != null) { for (GeneOntologyTerm term : selected) { CustomTimelineModel<GeneOntologyTerm> timeline = timelineMap.get(term); Set<EvidenceReference> evs = allCombinedDirectSeries.get(currentEdition).get(term); if (evs != null) { Set<String> grps = timelineGroups.get(term); for (String grp : grps) { EvidenceReference foundEV = null; for (EvidenceReference ev : evs) { if (ev.getCategory().equals(grp)) { foundEV = ev; break; } } if (foundEV != null) { TimelineEvent event = new TimelineEvent( foundEV.getReference() + "(|)" + foundEV.getEvidence(), currentEdition.getDate(), nextEdition.getDate(), false, grp, "timeline-true timeline-hidden"); timeline.add(event); } } } } } currentEdition = nextEdition; } // give the last edition a span of 1 month if (editions.size() > 1) { Calendar cal = Calendar.getInstance(); cal.setTime(currentEdition.getDate()); cal.add(Calendar.MONTH, 1); for (GeneOntologyTerm term : selected) { CustomTimelineModel<GeneOntologyTerm> timeline = timelineMap.get(term); Set<EvidenceReference> evs = allCombinedDirectSeries.get(currentEdition).get(term); if (evs != null) { Set<String> grps = timelineGroups.get(term); for (String grp : grps) { EvidenceReference foundEV = null; for (EvidenceReference ev : evs) { if (ev.getCategory().equals(grp)) { foundEV = ev; break; } } if (foundEV != null) { TimelineEvent event = new TimelineEvent( foundEV.getReference() + "(|)" + foundEV.getEvidence(), currentEdition.getDate(), cal.getTime(), false, grp, "timeline-true timeline-hidden"); timeline.add(event); } } } } } timelines = new ArrayList<>(timelineMap.values()); }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected Paint[] getPaintSequence(PlotSettings plotSettings, JRChartPlot jrPlot) { Paint[] colors = null;/*from w ww. j a va 2s. c om*/ SortedSet seriesColors = jrPlot.getSeriesColors(); Paint[] colorSequence = null; //The series gradient paint setting is considered first List themeSeriesPaintProvider = getChartThemeSettings().getPlotSettings() .getSeriesGradientPaintSequence() != null ? getChartThemeSettings().getPlotSettings().getSeriesGradientPaintSequence() : getChartThemeSettings().getPlotSettings().getSeriesColorSequence(); if (seriesColors != null && seriesColors.size() > 0) { int seriesColorsSize = seriesColors.size(); colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + seriesColorsSize]; JRSeriesColor[] jrColorSequence = new JRSeriesColor[seriesColorsSize]; seriesColors.toArray(jrColorSequence); colorSequence = new Paint[seriesColorsSize]; for (int i = 0; i < seriesColorsSize; i++) { colorSequence[i] = jrColorSequence[i].getColor(); } populateSeriesColors(colors, colorSequence); } else if (themeSeriesPaintProvider != null && !themeSeriesPaintProvider.isEmpty()) { colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + themeSeriesPaintProvider.size()]; colorSequence = new Paint[themeSeriesPaintProvider.size()]; List themeSeriesColors = new ArrayList(); for (int i = 0; i < themeSeriesPaintProvider.size(); i++) { themeSeriesColors.add(((PaintProvider) themeSeriesPaintProvider.get(i)).getPaint()); } themeSeriesColors.toArray(colorSequence); populateSeriesColors(colors, colorSequence); } else { colors = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE; } return colors; }
From source file:org.wso2.carbon.appmgt.impl.utils.AppManagerUtil.java
public static Set<AppStore> getExternalAPIStores() throws AppManagementException { SortedSet<AppStore> apistoreSet = new TreeSet<AppStore>(new APIStoreNameComparator()); AppManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService() .getAPIManagerConfiguration(); apistoreSet.addAll(config.getExternalAPIStores()); if (apistoreSet.size() != 0) { return apistoreSet; } else {//from w w w.j a v a 2 s . c o m return null; } }
From source file:de.uni_potsdam.hpi.asg.logictool.mapping.SequenceBasedAndGateDecomposer.java
public boolean decomposeAND(NetlistTerm term) { logger.info("Decomposition of " + term.toString()); Set<Signal> signals = netlist.getDrivenSignalsTransitive(term); if (signals.isEmpty()) { logger.warn("No signal(s) for term " + term + " found"); return false; } else if (signals.size() > 1) { logger.warn("Term " + term + " drives more than one signal. This is not supported yet"); return false; }/* w w w . ja v a2 s . c om*/ Signal origsig = signals.iterator().next(); if (!isAOC(term, origsig)) { logger.warn("Algorithm not applicable for non-AOC architectures"); return false; } int startgatesize = BDDHelper.numberOfVars(term.getBdd()); BDD bdd = term.getBdd(); Set<Signal> origrelevant = findRelevantSigs(bdd); if (origrelevant == null) { return false; } StateGraph sg2 = sghelper.getNewStateGraph(origrelevant, origsig); if (sg2 == null) { logger.warn("Failed to generate new SG. Using the original one."); sg2 = origsg; } BiMap<Signal, Signal> sigmap = HashBiMap.create(); Set<Signal> relevant = new HashSet<>(); boolean found; for (Signal oldSig : origrelevant) { found = false; for (Signal newSig : sg2.getAllSignals()) { if (oldSig.getName().equals(newSig.getName())) { sigmap.put(oldSig, newSig); found = true; break; } } if (!found) { logger.error("Signal " + oldSig.getName() + " not found"); return false; } relevant.add(sigmap.get(oldSig)); } found = false; for (Signal newSig : sg2.getAllSignals()) { if (origsig.getName().equals(newSig.getName())) { sigmap.put(origsig, newSig); found = true; break; } } if (!found) { logger.error("Signal " + origsig.getName() + " not found"); return false; } Signal sig = sigmap.get(origsig); Map<Signal, Boolean> posnegmap = getInputsPosOrNeg(term, sigmap); BDD newbdd = factory.one(); for (Entry<Signal, Boolean> entry : posnegmap.entrySet()) { if (entry.getValue()) { newbdd = newbdd.andWith(getPosBDD(entry.getKey())); } else { newbdd = newbdd.andWith(getNegBDD(entry.getKey())); } if (entry.getKey() instanceof QuasiSignal) { relevant.add(entry.getKey()); } } Set<State> startStates = new HashSet<>(); for (State s : sg2.getStates()) { for (Entry<Transition, State> entry2 : s.getNextStates().entrySet()) { if (entry2.getKey().getSignal() == sig) { startStates.add(entry2.getValue()); } } } List<List<Signal>> fallingPartitions = new ArrayList<>(); for (Signal sig2 : relevant) { List<Signal> tmp = new ArrayList<>(); tmp.add(sig2); fallingPartitions.add(tmp); } SortedSet<IOBehaviour> sequencesFront = new TreeSet<>(new SequenceFrontCmp()); SortedSet<IOBehaviour> sequencesBack = new TreeSet<>(new SequenceBackCmp()); Set<IOBehaviour> newSequences = new HashSet<>(); Set<IOBehaviour> rmSequences = new HashSet<>(); Deque<IOBehaviourSimulationStep> steps = new ArrayDeque<>(); pool = new IOBehaviourSimulationStepPool(new IOBehaviourSimulationStepFactory()); pool.setMaxTotal(-1); try { root = pool.borrowObject(); } catch (Exception e) { e.printStackTrace(); logger.error("Could not borrow object"); return false; } IOBehaviourSimulationStep newStep; for (State s : startStates) { try { newStep = pool.borrowObject(); } catch (Exception e) { e.printStackTrace(); logger.error("Could not borrow object"); return false; } root.getNextSteps().add(newStep); newStep.setPrevStep(root); newStep.setStart(s); newStep.setNextState(s); steps.add(newStep); } if (steps.isEmpty()) { return false; } final long checkThreshold = 100; long stepsEvaledTotal = 0; IOBehaviourSimulationStep step = null; while (!steps.isEmpty()) { step = steps.removeLast(); // System.out.println("#Step: " + step.toString()); getNewSteps(step, sig, newSequences, steps, relevant); stepsEvaledTotal++; if (newSequences.size() >= checkThreshold) { removeCandidates(sequencesFront, sequencesBack, newSequences, rmSequences); } } removeCandidates(sequencesFront, sequencesBack, newSequences, rmSequences); logger.debug("Sequences: " + sequencesFront.size() + " - Tmp Sequences: " + newSequences.size() + " - Steps to evaluate: " + steps.size() + " - Steps evaluated: " + stepsEvaledTotal); logger.debug("Pool: " + "Created: " + pool.getCreatedCount() + ", Borrowed: " + pool.getBorrowedCount() + ", Returned: " + pool.getReturnedCount() + ", Active: " + pool.getNumActive() + ", Idle: " + pool.getNumIdle()); logger.debug("RmSub: " + rmSub + " // RmFall: " + rmFall); SortedSet<IOBehaviour> sequences = new TreeSet<>(sequencesFront); sequencesFront.clear(); sequencesBack.clear(); // System.out.println(sequences.toString()); List<IOBehaviour> falling = new ArrayList<>(); List<IOBehaviour> rising = new ArrayList<>(); List<IOBehaviour> constant = new ArrayList<>(); if (!categoriseSequences(newbdd, sequences, falling, rising, constant)) { return false; } // System.out.println("Falling:"); // for(IOBehaviour beh : falling) { // System.out.println(beh.toString()); // } // System.out.println("Rising:"); // for(IOBehaviour beh : rising) { // System.out.println(beh.toString()); // } // System.out.println("Constant:"); // for(IOBehaviour beh : constant) { // System.out.println(beh.toString()); // } fallingPartitions = getPossiblePartitionsFromFalling(falling, relevant); // System.out.println("FallingPartitions: " + fallingPartitions.toString()); Map<Integer, List<Partition>> partitions = getPartitions(relevant, startgatesize); if (partitions == null) { logger.error("There was a problem while creating partions for signal " + sig.getName()); return false; } // System.out.println("Init:"); // for(Entry<Integer, List<Partition>> entry : partitions.entrySet()) { // System.out.println(entry.getKey()); // for(Partition p : entry.getValue()) { // System.out.println("\t" + p.toString()); // } // } filterPartitions(partitions, fallingPartitions); if (partitions.isEmpty()) { logger.error("No suitable partions found"); return false; } // System.out.println("After filter Falling:"); // for(Entry<Integer, List<Partition>> entry : partitions.entrySet()) { // System.out.println(entry.getKey()); // for(Partition p : entry.getValue()) { // System.out.println("\t" + p.toString()); // } // } // System.out.println("posneg: " + posnegmap.toString()); setPartitionBDDs(partitions, posnegmap); if (!checkRising(rising, partitions)) { logger.error("Check rising failed"); return false; } if (partitions.isEmpty()) { logger.error("No suitable partions found"); return false; } // System.out.println("After filter Rising:"); // for(Entry<Integer, List<Partition>> entry : partitions.entrySet()) { // System.out.println(entry.getKey()); // for(Partition p : entry.getValue()) { // System.out.println("\t" + p.toString()); // } // } if (!checkConstant(constant, partitions)) { logger.error("Check constant failed"); return false; } if (partitions.isEmpty()) { logger.error("No suitable partions found"); return false; } // System.out.println("After filter Constant:"); // for(Entry<Integer, List<Partition>> entry : partitions.entrySet()) { // System.out.println(entry.getKey()); // for(Partition p : entry.getValue()) { // System.out.println("\t" + p.toString()); // } // } applyDecoResult(term, partitions, posnegmap, sigmap); return true; }
From source file:org.wso2.carbon.appmgt.impl.utils.AppManagerUtil.java
public static Set<AppStore> getExternalAPIStores(Set<AppStore> inputStores) throws AppManagementException { SortedSet<AppStore> apiStores = new TreeSet<AppStore>(new APIStoreNameComparator()); AppManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService() .getAPIManagerConfiguration(); apiStores.addAll(config.getExternalAPIStores()); boolean exists = false; if (apiStores.size() != 0) { for (AppStore store : apiStores) { for (AppStore inputStore : inputStores) { if (inputStore.getName().equals(store.getName())) { // If // the // configured // appstore // already // stored // in // db,ignore // adding // it // again exists = true;/*w ww .j ava 2 s. c om*/ } } if (!exists) { inputStores.add(store); } exists = false; } } return inputStores; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
protected Paint[] getPaintSequence(PlotSettings plotSettings, JRChartPlot jrPlot) { Paint[] colors = null;/*from www .j a va2 s .c om*/ SortedSet<JRSeriesColor> seriesColors = jrPlot.getSeriesColors(); Paint[] colorSequence = null; //The series gradient paint setting is considered first List<PaintProvider> themeSeriesPaintProvider = getChartThemeSettings().getPlotSettings() .getSeriesGradientPaintSequence() != null ? getChartThemeSettings().getPlotSettings().getSeriesGradientPaintSequence() : getChartThemeSettings().getPlotSettings().getSeriesColorSequence(); if (seriesColors != null && seriesColors.size() > 0) { int seriesColorsSize = seriesColors.size(); colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + seriesColorsSize]; JRSeriesColor[] jrColorSequence = new JRSeriesColor[seriesColorsSize]; seriesColors.toArray(jrColorSequence); colorSequence = new Paint[seriesColorsSize]; for (int i = 0; i < seriesColorsSize; i++) { colorSequence[i] = jrColorSequence[i].getColor(); } populateSeriesColors(colors, colorSequence); } else if (themeSeriesPaintProvider != null && !themeSeriesPaintProvider.isEmpty()) { colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + themeSeriesPaintProvider.size()]; colorSequence = new Paint[themeSeriesPaintProvider.size()]; List<Paint> themeSeriesColors = new ArrayList<Paint>(); for (int i = 0; i < themeSeriesPaintProvider.size(); i++) { themeSeriesColors.add(themeSeriesPaintProvider.get(i).getPaint()); } themeSeriesColors.toArray(colorSequence); populateSeriesColors(colors, colorSequence); } else { colors = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE; } return colors; }
From source file:com.stratelia.silverpeas.pdcPeas.servlets.PdcSearchRequestRouter.java
/** * Cette mthode est appelle uniquement lorsque l'utilisateur fait une recherche combinant la * recherche classique la recherche PDC. Elle rcupre dans une liste tous les documents se * trouvant positionns dans le PDC de ie. Puis elle ne garde, que les elements communs entre les * deux listes - celle cre et celle des silvercontentid. Ensuite, elle rcupre les * MatchinIndexEntry correspondant aux rsultats du tri des listes. * * @param ie - le tableau de MatchingIndexEntry trouv par la recherche classique * @return le nouveau tableau de MatchingIndexEntry. *//*from www. ja v a2 s . co m*/ private MatchingIndexEntry[] mixedSearch(MatchingIndexEntry[] ie, List<Integer> alSilverContentIds) throws Exception { // On crait une liste trie d'indexEntry SortedSet<Integer> basicSearchList = new TreeSet<Integer>(); List<String> docFeature = new ArrayList<String>(); for (int i = 0; ie != null && i < ie.length; i++) { String instanceId = ie[i].getComponent(); // recupere l'instanceId String objectId = ie[i].getObjectId(); // recupere l'id du document docFeature.add(objectId); docFeature.add(instanceId); } try { // on rcupre le silverContentId partir de la recherche classique basicSearchList = contentManager.getSilverContentId(docFeature); } catch (Exception e) { SilverTrace.info("pdcPeas", "PdcSearchRequestRouteur.mixedSearch", "root.MSG_GEN_EXIT_METHOD"); } // ne garde que les objets communs aux 2 listes basicSearchList - alSilverContentIds // en effet, la liste resultante du PDC n'est pas la meme que celle // labore partir de la recherche classique if (alSilverContentIds != null) { basicSearchList.retainAll(alSilverContentIds); } // la liste basicSearchList ne contient maintenant que les silverContentIds des documents // trouvs // mais ces documents sont galement dans le tableau rsultat de la recherche classique // il faut donc crer un tableau de MatchingIndexEntry pour afficher le resultat List<MatchingIndexEntry> result = new ArrayList<MatchingIndexEntry>(); if (basicSearchList != null && basicSearchList.size() > 0) { // la liste contient bien des rsultats Iterator<Integer> it = basicSearchList.iterator(); for (; it.hasNext();) { int contentId = it.next().intValue(); // on rcupre le silverContentId de la // liste // on rcupre l'internalContentId car nous en avons besoin pour la construction d'un // matchingIndexEntry String internalContentId = contentManager.getInternalContentId(contentId); MatchingIndexEntry mie = getMatchingIndexEntry(ie, internalContentId); if (mie != null) { result.add(mie); } } } Collections.sort(result, ScoreComparator.comparator); return result.toArray(new MatchingIndexEntry[0]); }
From source file:de.interactive_instruments.ShapeChange.Target.FeatureCatalogue.FeatureCatalogue.java
public void initialise(PackageInfo p, Model m, Options o, ShapeChangeResult r, boolean diagOnly) throws ShapeChangeAbortException { pi = p;/*from ww w . ja v a 2s. c o m*/ model = m; options = o; result = r; try { if (!initialised) { initialised = true; String pathToJavaExe_ = options.parameter(this.getClass().getName(), PARAM_JAVA_EXE_PATH); if (pathToJavaExe_ != null && pathToJavaExe_.trim().length() > 0) { pathToJavaExe = pathToJavaExe_.trim(); if (!pathToJavaExe.startsWith("\"")) { pathToJavaExe = "\"" + pathToJavaExe; } if (!pathToJavaExe.endsWith("\"")) { pathToJavaExe = pathToJavaExe + "\""; } String jo_tmp = options.parameter(this.getClass().getName(), PARAM_JAVA_OPTIONS); if (jo_tmp != null && jo_tmp.trim().length() > 0) { javaOptions = jo_tmp.trim(); } /* * check path - and potentially also options - by invoking * the exe */ List<String> cmds = new ArrayList<String>(); cmds.add(pathToJavaExe); if (javaOptions != null) { cmds.add(javaOptions); } cmds.add("-version"); ProcessBuilder pb = new ProcessBuilder(cmds); try { Process proc = pb.start(); StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream()); StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream()); errorGobbler.start(); outputGobbler.start(); errorGobbler.join(); outputGobbler.join(); int exitVal = proc.waitFor(); if (exitVal != 0) { if (errorGobbler.hasResult()) { MessageContext mc = result.addFatalError(this, 21, StringUtils.join(cmds, " "), "" + exitVal); mc.addDetail(this, 27, errorGobbler.getResult()); } else { result.addFatalError(this, 21, StringUtils.join(cmds, " "), "" + exitVal); } throw new ShapeChangeAbortException(); } } catch (InterruptedException e) { result.addFatalError(this, 22); throw new ShapeChangeAbortException(); } } encounteredAppSchemasByName = new TreeMap<String, Integer>(); initialiseFromOptions(); String s = null; Model refModel_tmp = getReferenceModel(); if (refModel_tmp != null) { /* * Ensure that IDs used in the reference model are unique to * that model and do not get mixed up with the IDs of the * input model. * * REQUIREMENT for model diff: two objects with equal ID * must represent the same model element. If a model element * is deleted in the reference model, then a new model * element in the input model must not have the same ID. * * It looks like this cannot be guaranteed. Therefore we add * a prefix to the IDs of the model elements in the * reference model. */ refModel = new GenericModel(refModel_tmp); refModel_tmp.shutdown(); refModel.addPrefixToModelElementIDs("refmodel_"); } String xmlName = outputFilename + ".tmp.xml"; // Check whether we can use the given output directory File outputDirectoryFile = new File(outputDirectory); boolean exi = outputDirectoryFile.exists(); if (!exi) { outputDirectoryFile.mkdirs(); exi = outputDirectoryFile.exists(); } boolean dir = outputDirectoryFile.isDirectory(); boolean wrt = outputDirectoryFile.canWrite(); boolean rea = outputDirectoryFile.canRead(); if (!exi || !dir || !wrt || !rea) { result.addFatalError(this, 12, outputDirectory); throw new ShapeChangeAbortException(); } String encoding_ = encoding == null ? "UTF-8" : model.characterEncoding(); OutputStream fout = new FileOutputStream(outputDirectory + "/" + xmlName); OutputStream bout = new BufferedOutputStream(fout, streamBufferSize); OutputStreamWriter outputXML = new OutputStreamWriter(bout, encoding_); writer = new XMLWriter(outputXML, encoding_); writer.forceNSDecl("http://www.w3.org/2001/XMLSchema-instance", "xsi"); writer.startDocument(); writer.processingInstruction("xml-stylesheet", "type='text/xsl' href='./html.xsl'"); writer.comment("Feature catalogue created using ShapeChange"); AttributesImpl atts = new AttributesImpl(); atts.addAttribute("http://www.w3.org/2001/XMLSchema-instance", "noNamespaceSchemaLocation", "xsi:noNamespaceSchemaLocation", "CDATA", "FC.xsd"); writer.startElement("", "FeatureCatalogue", "", atts); s = options.parameter(this.getClass().getName(), "name"); if (s != null && s.length() > 0) writer.dataElement("name", s); else writer.dataElement("name", "unknown"); s = options.parameter(this.getClass().getName(), "scope"); if (s != null && s.length() > 0) PrintLineByLine(s, "scope", null); else { writer.dataElement("scope", "unknown"); } s = options.parameter(this.getClass().getName(), "versionNumber"); if (s != null && s.length() > 0) writer.dataElement("versionNumber", s); else writer.dataElement("versionNumber", "unknown"); s = options.parameter(this.getClass().getName(), "versionDate"); if (s != null && s.length() > 0) writer.dataElement("versionDate", s); else writer.dataElement("versionDate", "unknown"); s = options.parameter(this.getClass().getName(), "producer"); if (s != null && s.length() > 0) writer.dataElement("producer", s); else writer.dataElement("producer", "unknown"); } // we need to compute the diff for each application schema if (refModel != null) { SortedSet<PackageInfo> set = refModel.schemas(p.name()); if (set.size() == 1) { /* * Get the full names of classes (in lower case) from the * input schema so that later we can look them up by their * full name (within the schema, not in the model). */ inputSchemaClassesByFullNameInSchema = new HashMap<String, ClassInfo>(); for (ClassInfo ci : model.classes(pi)) { inputSchemaClassesByFullNameInSchema.put(ci.fullNameInSchema().toLowerCase(Locale.ENGLISH), ci); } // compute diffs differ = new Differ(); refPackage = set.iterator().next(); SortedMap<Info, SortedSet<DiffElement>> pi_diffs = differ.diff(p, refPackage); // merge diffs for pi with existing diffs (from other // schemas) differ.merge(diffs, pi_diffs); // log the diffs found for pi for (Entry<Info, SortedSet<DiffElement>> me : pi_diffs.entrySet()) { MessageContext mc = result.addInfo( "Model difference - " + me.getKey().fullName().replace(p.fullName(), p.name())); for (DiffElement diff : me.getValue()) { String s = diff.change + " " + diff.subElementType; if (diff.subElementType == ElementType.TAG) s += "(" + diff.tag + ")"; if (diff.subElement != null) s += " " + diff.subElement.name(); else if (diff.diff != null) s += " " + (new diff_match_patch()).diff_prettyHtml(diff.diff); else s += " ???"; mc.addDetail(s); } } /* * switch to default xslt for html diff - unless the * configuration explicitly names an XSLT file to use */ if (options.parameter(this.getClass().getName(), "xslhtmlFile") == null) { xslhtmlfileName = DEFAULT_XSL_HTML_DIFF_FILE_NAME; } } else { result.addWarning(null, 308, p.name()); refModel = null; } } writer.startElement("ApplicationSchema", "id", "_P" + pi.id()); /* * Determine if app schema with same name has been encountered * before, and choose name accordingly */ String nameForAppSchema = null; if (encounteredAppSchemasByName.containsKey(pi.name())) { int count = encounteredAppSchemasByName.get(pi.name()).intValue(); count++; nameForAppSchema = pi.name() + " (" + count + ")"; encounteredAppSchemasByName.put(pi.name(), new Integer(count)); } else { nameForAppSchema = pi.name(); encounteredAppSchemasByName.put(pi.name(), new Integer(1)); } // now set the name of the application schema writer.dataElement("name", nameForAppSchema); String s = pi.definition(); if (s != null && s.length() > 0) { PrintLineByLine(s, "definition", null); } s = pi.description(); if (s != null && s.length() > 0) { PrintLineByLine(s, "description", null); } s = pi.version(); if (s != null && s.length() > 0) { writer.dataElement("versionNumber", s); } writer.startElement("taggedValues"); s = pi.taggedValue(TransformationConstants.TRF_TV_NAME_GENERATIONDATETIME); if (s != null && s.trim().length() > 0) { writer.dataElement(TransformationConstants.TRF_TV_NAME_GENERATIONDATETIME, PrepareToPrint(s)); } writer.endElement("taggedValues"); if (pi.getDiagrams() != null) { appendImageInfo(pi.getDiagrams()); } writer.endElement("ApplicationSchema"); /* * Check if there are any deletions of classes or packages that are * owned by the application schema package. */ if (hasDiff(pi, ElementType.SUBPACKAGE, Operation.DELETE)) { Set<DiffElement> pkgdiffs = getDiffs(pi, ElementType.SUBPACKAGE, Operation.DELETE); for (DiffElement diff : pkgdiffs) { // child package was deleted PrintPackage((PackageInfo) diff.subElement, Operation.DELETE); } } printContainedPackages(pi); /* * NOTE: inserted or unchanged classes are handled in * process(ClassInfo) method */ printDeletedClasses(pi); } catch (Exception e) { String msg = e.getMessage(); if (msg != null) { result.addError(msg); } e.printStackTrace(System.err); } }