Esempio n. 1
0
  protected List<Difference> summarizedDifferencesOfPaths(
      List<? extends Difference> singletonDiffs) {
    Map<String, Difference> summaries = new HashMap<String, Difference>();

    // create the initial set of differences
    for (int i = 0; i < singletonDiffs.size(); i++) {
      for (int j = 0; j <= i; j++) {
        Difference diffPath1 = singletonDiffs.get(i);
        Difference diffPath2 = singletonDiffs.get(j);
        if (diffPath1.length() == diffPath2.length()) {
          int lcp = longestCommonPostfix(diffPath1.getParts(), diffPath2.getParts());
          String path = diffPath2.getPath();
          if (lcp != 0 && lcp != diffPath1.length())
            path = summarizedPath(diffPath2.getParts(), lcp);
          Difference sumDiff = new Difference(path, diffPath2.getMaster(), diffPath2.getTest());
          sumDiff.setCount(0);
          addSummaryIfMissing(summaries, sumDiff);
        }
      }
    }

    // count differences
    for (Difference diffPath : singletonDiffs) {
      for (Difference sumDiff : summaries.values()) {
        if (sumDiff.matches(diffPath.getParts())) sumDiff.incCount();
      }
    }

    List<Difference> sortedSummaries = new ArrayList<Difference>(summaries.values());
    Collections.sort(sortedSummaries);
    return sortedSummaries;
  }
Esempio n. 2
0
 @Override
 public List<PermissionOverride> getPermissionOverrides() {
   List<PermissionOverride> overrides = new LinkedList<>();
   overrides.addAll(userPermissionOverrides.values());
   overrides.addAll(rolePermissionOverrides.values());
   return Collections.unmodifiableList(overrides);
 }
Esempio n. 3
0
 private void checkAccessors(
     @NotNull JetProperty property, @NotNull PropertyDescriptor propertyDescriptor) {
   for (JetPropertyAccessor accessor : property.getAccessors()) {
     PropertyAccessorDescriptor propertyAccessorDescriptor =
         accessor.isGetter() ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter();
     assert propertyAccessorDescriptor != null
         : "No property accessor descriptor for " + property.getText();
     modifiersChecker.checkModifiersForDeclaration(accessor, propertyAccessorDescriptor);
     modifiersChecker.reportIllegalModalityModifiers(accessor);
   }
   JetPropertyAccessor getter = property.getGetter();
   PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter();
   JetModifierList getterModifierList = getter != null ? getter.getModifierList() : null;
   if (getterModifierList != null && getterDescriptor != null) {
     Map<JetModifierKeywordToken, ASTNode> nodes =
         ModifiersChecker.getNodesCorrespondingToModifiers(
             getterModifierList,
             Sets.newHashSet(
                 JetTokens.PUBLIC_KEYWORD,
                 JetTokens.PROTECTED_KEYWORD,
                 JetTokens.PRIVATE_KEYWORD,
                 JetTokens.INTERNAL_KEYWORD));
     if (getterDescriptor.getVisibility() != propertyDescriptor.getVisibility()) {
       for (ASTNode node : nodes.values()) {
         trace.report(Errors.GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY.on(node.getPsi()));
       }
     } else {
       for (ASTNode node : nodes.values()) {
         trace.report(Errors.REDUNDANT_MODIFIER_IN_GETTER.on(node.getPsi()));
       }
     }
   }
 }
 private void parameterFormatAnalysis() {
   publish("Parameter Format Analysis...");
   int total =
       urlParameters.size()
           + bodyParameters.size()
           + cookieParameters.size()
           + jsonParameters.size();
   int i = 0;
   publish(0);
   for (CorrelatedParam cp : urlParameters.values()) {
     cp.analyzeAll(callbacks);
     i += 1;
     publish(100 * i / total);
   }
   for (CorrelatedParam cp : bodyParameters.values()) {
     cp.analyzeAll(callbacks);
     i += 1;
     publish(100 * i / total);
   }
   for (CorrelatedParam cp : cookieParameters.values()) {
     cp.analyzeAll(callbacks);
     i += 1;
     publish(100 * i / total);
   }
   for (CorrelatedParam cp : jsonParameters.values()) {
     cp.analyzeAll(callbacks);
     i += 1;
     publish(100 * i / total);
   }
 }
  /**
   * Asks current editor to refresh its state in accordance with the arrangement rule shown at the
   * given row.
   *
   * @param row row index of the rule which match condition should be edited (if defined); <code>
   *     '-1'</code> as an indication that no settings should be active
   */
  public void reset(int row) {
    // Reset state.
    myRow = row;
    myFocusRequestor = myDefaultFocusRequestor;
    mySkipStateChange = true;
    try {
      for (ArrangementUiComponent component : myComponents.values()) {
        component.reset();
      }
    } finally {
      mySkipStateChange = false;
    }

    ArrangementMatchingRulesModel model = myControl.getModel();
    if (row < 0 || row >= model.getSize()) {
      myRow = -1;
      return;
    }

    Object element = model.getElementAt(row);
    ArrangementSettingsToken orderType =
        element instanceof ArrangementMatchRule
            ? ((ArrangementMatchRule) element).getOrderType()
            : null;
    final ArrangementMatchCondition condition;
    final Map<ArrangementSettingsToken, Object> conditionTokens;

    if (element instanceof EmptyArrangementRuleComponent) {
      // We need to disable conditions which are not applicable for empty rules (e.g. we don't want
      // to enable 'volatile' condition
      // for java rearranger if no 'field' condition is selected.
      condition = null;
      conditionTokens = ContainerUtilRt.newHashMap();
    } else if (!(element instanceof StdArrangementMatchRule)) {
      return;
    } else {
      condition = ((StdArrangementMatchRule) element).getMatcher().getCondition();
      conditionTokens = ArrangementUtil.extractTokens(condition);
    }

    mySkipStateChange = true;
    try {
      for (ArrangementUiComponent component : myComponents.values()) {
        ArrangementSettingsToken token = component.getToken();
        if (token != null
            && (token.equals(orderType) || mySettingsManager.isEnabled(token, condition))) {
          component.setEnabled(true);
          component.setSelected(conditionTokens.containsKey(token));
          Object value = conditionTokens.get(token);
          if (value != null) {
            component.setData(value);
          }
        }
      }

      refreshConditions();
    } finally {
      mySkipStateChange = false;
    }
  }
Esempio n. 6
0
 public Collection<TransferCapability> getTransferCapabilities() {
   ArrayList<TransferCapability> tcs =
       new ArrayList<TransferCapability>(scuTCs.size() + scpTCs.size());
   tcs.addAll(scpTCs.values());
   tcs.addAll(scuTCs.values());
   return tcs;
 }
  public void displayConfusionMatrix() {
    int total = 0;
    int wrong = 0;
    System.out.print("  |   ");
    for (Category c : categories.values()) {
      System.out.print(c.getCategory() + "  |   ");
      total += c.totalCategorized;
      wrong += c.wrong;
    }
    System.out.println();

    for (Category c : categories.values()) {
      String out = c.getCategory() + " | ";
      for (String c2 : categories.keySet()) {
        if (c.categorized.containsKey(c2))
          out += String.format("%.2f | ", c.categorized.get(c2) / (c.totalCategorized * 1.0));
        else out += "0000 | ";
      }
      System.out.println(out);
    }

    System.out.println("Accuracy: " + Math.round(100 * (total - wrong * 1.0) / total) + "%");

    System.out.println();
  }
Esempio n. 8
0
  /**
   * Generate mapping for the sub-classes for every class in this run. Return the sub-class list for
   * java.lang.Object which will be having sub-class listing for itself and also for each sub-class
   * itself will have their own sub-class lists.
   *
   * @param classes all the classes in this run.
   * @param configuration the current configuration of the doclet.
   */
  private void buildTree(ClassDoc[] classes, Configuration configuration) {
    log.info("ClassTree buildTree");
    for (int i = 0; i < classes.length; i++) {
      if (configuration.nodeprecated && classes[i].tags("deprecated").length > 0) {
        continue;
      }
      if (classes[i].isEnum()) {
        processType(classes[i], configuration, baseEnums, subEnums);
      } else if (classes[i].isClass()) {
        processType(classes[i], configuration, baseclasses, subclasses);
      } else if (classes[i].isInterface()) {
        processInterface(classes[i]);
        List list = (List) implementingclasses.get(classes[i]);
        if (list != null) {
          Collections.sort(list);
        }
      } else if (classes[i].isAnnotationType()) {
        processType(classes[i], configuration, baseAnnotationTypes, subAnnotationTypes);
      }
    }

    Collections.sort(baseinterfaces);
    for (Iterator it = subinterfaces.values().iterator(); it.hasNext(); ) {
      Collections.sort((List) it.next());
    }
    for (Iterator it = subclasses.values().iterator(); it.hasNext(); ) {
      Collections.sort((List) it.next());
    }
  }
  /**
   * Query all purchases made at a specific store for 3 specific products. This query uses
   * cross-cache joins between {@link DimStore}, {@link DimProduct} objects stored in {@code
   * 'replicated'} cache and {@link FactPurchase} objects stored in {@code 'partitioned'} cache.
   *
   * @throws IgniteException If failed.
   */
  private static void queryProductPurchases() {
    IgniteCache<Integer, FactPurchase> factCache = Ignition.ignite().cache(PARTITIONED_CACHE_NAME);

    // All purchases for certain product made at store2.
    // =================================================

    DimProduct p1 = rand(dataProduct.values());
    DimProduct p2 = rand(dataProduct.values());
    DimProduct p3 = rand(dataProduct.values());

    System.out.println(
        "IDs of products [p1=" + p1.getId() + ", p2=" + p2.getId() + ", p3=" + p3.getId() + ']');

    // Create cross cache query to get all purchases made at store2
    // for specified products.
    QueryCursor<Cache.Entry<Integer, FactPurchase>> prodPurchases =
        factCache.query(
            new SqlQuery(
                    FactPurchase.class,
                    "from \""
                        + REPLICATED_CACHE_NAME
                        + "\".DimStore, \""
                        + REPLICATED_CACHE_NAME
                        + "\".DimProduct, "
                        + "\""
                        + PARTITIONED_CACHE_NAME
                        + "\".FactPurchase "
                        + "where DimStore.id=FactPurchase.storeId and DimProduct.id=FactPurchase.productId "
                        + "and DimStore.name=? and DimProduct.id in(?, ?, ?)")
                .setArgs("Store2", p1.getId(), p2.getId(), p3.getId()));

    printQueryResults(
        "All purchases made at store2 for 3 specific products:", prodPurchases.getAll());
  }
  public void checkLineMarkers(
      @NotNull Collection<LineMarkerInfo> markerInfos, @NotNull String text) {
    String fileName = myFile == null ? "" : myFile.getName() + ": ";
    String failMessage = "";

    for (LineMarkerInfo info : markerInfos) {
      if (!containsLineMarker(info, myLineMarkerInfos.values())) {
        if (!failMessage.isEmpty()) failMessage += '\n';
        failMessage +=
            fileName
                + "Extra line marker highlighted "
                + rangeString(text, info.startOffset, info.endOffset)
                + ": '"
                + info.getLineMarkerTooltip()
                + "'";
      }
    }

    for (LineMarkerInfo expectedLineMarker : myLineMarkerInfos.values()) {
      if (!markerInfos.isEmpty() && !containsLineMarker(expectedLineMarker, markerInfos)) {
        if (!failMessage.isEmpty()) failMessage += '\n';
        failMessage +=
            fileName
                + "Line marker was not highlighted "
                + rangeString(text, expectedLineMarker.startOffset, expectedLineMarker.endOffset)
                + ": '"
                + expectedLineMarker.getLineMarkerTooltip()
                + "'";
      }
    }

    if (!failMessage.isEmpty()) Assert.fail(failMessage);
  }
Esempio n. 11
0
  public GraphIndex(Graph graph) {
    LOG.info("Indexing graph...");

    for (String feedId : graph.getFeedIds()) {
      for (Agency agency : graph.getAgencies(feedId)) {
        Map<String, Agency> agencyForId = agenciesForFeedId.getOrDefault(feedId, new HashMap<>());
        agencyForId.put(agency.getId(), agency);
        this.agenciesForFeedId.put(feedId, agencyForId);
      }
    }

    Collection<Edge> edges = graph.getEdges();
    /* We will keep a separate set of all vertices in case some have the same label.
     * Maybe we should just guarantee unique labels. */
    Set<Vertex> vertices = Sets.newHashSet();
    for (Edge edge : edges) {
      vertices.add(edge.getFromVertex());
      vertices.add(edge.getToVertex());
      if (edge instanceof TablePatternEdge) {
        TablePatternEdge patternEdge = (TablePatternEdge) edge;
        TripPattern pattern = patternEdge.getPattern();
        patternForId.put(pattern.code, pattern);
      }
    }
    for (Vertex vertex : vertices) {
      vertexForId.put(vertex.getLabel(), vertex);
      if (vertex instanceof TransitStop) {
        TransitStop transitStop = (TransitStop) vertex;
        Stop stop = transitStop.getStop();
        stopForId.put(stop.getId(), stop);
        stopVertexForStop.put(stop, transitStop);
        stopsForParentStation.put(stop.getParentStation(), stop);
      }
    }
    for (TransitStop stopVertex : stopVertexForStop.values()) {
      Envelope envelope = new Envelope(stopVertex.getCoordinate());
      stopSpatialIndex.insert(envelope, stopVertex);
    }
    for (TripPattern pattern : patternForId.values()) {
      patternsForFeedId.put(pattern.getFeedId(), pattern);
      patternsForRoute.put(pattern.route, pattern);

      for (Trip trip : pattern.getTrips()) {
        patternForTrip.put(trip, pattern);
        tripForId.put(trip.getId(), trip);
      }
      for (Stop stop : pattern.getStops()) {
        patternsForStop.put(stop, pattern);
      }
    }
    for (Route route : patternsForRoute.asMap().keySet()) {
      routeForId.put(route.getId(), route);
    }

    // Copy these two service indexes from the graph until we have better ones.
    calendarService = graph.getCalendarService();
    serviceCodes = graph.serviceCodes;
    this.graph = graph;
    LOG.info("Done indexing graph.");
  }
  void release() {
    if (childRowToIdMap != null) {
      Collection delegates = childRowToIdMap.values();
      Iterator iter = delegates.iterator();
      while (iter.hasNext()) {
        SWTAccessibleDelegate childDelegate = ((Accessible) iter.next()).delegate;
        if (childDelegate != null) {
          childDelegate.internal_dispose_SWTAccessibleDelegate();
          childDelegate.release();
        }
      }

      childRowToIdMap.clear();
      childRowToIdMap = null;
    }

    if (childColumnToIdMap != null) {
      Collection delegates = childColumnToIdMap.values();
      Iterator iter = delegates.iterator();
      while (iter.hasNext()) {
        SWTAccessibleDelegate childDelegate = ((Accessible) iter.next()).delegate;
        if (childDelegate != null) {
          childDelegate.internal_dispose_SWTAccessibleDelegate();
          childDelegate.release();
        }
      }

      childColumnToIdMap.clear();
      childColumnToIdMap = null;
    }
  }
  public void search(String filename) throws IOException {
    List<GeneAlt[]> pairs = new ArrayList<GeneAlt[]>();
    for (GeneAlt g1 : genes.values()) {
      for (GeneAlt g2 : genes.values()) {
        if (g1.getId().compareTo(g2.getId()) < 0) {
          pairs.add(new GeneAlt[] {g1, g2});
        }
      }
    }

    final Map<GeneAlt[], Double> pvals = new HashMap<GeneAlt[], Double>();
    for (GeneAlt[] pair : pairs) {
      pvals.put(
          pair, Overlap.calcMutexPval(pair[0].getBooleanChanges(), pair[1].getBooleanChanges()));
    }

    Collections.sort(pairs, (o1, o2) -> pvals.get(o1).compareTo(pvals.get(o2)));

    BufferedWriter writer = new BufferedWriter(new FileWriter(filename));

    for (GeneAlt[] pair : pairs) {
      writer.write(pair[0].getId() + "\t" + pair[1].getId() + "\n");
    }

    writer.close();
  }
Esempio n. 14
0
  @Override
  public void execute(Tuple tuple) {
    List<Object> id = tuple.select(_idFields);
    GlobalStreamId streamId =
        new GlobalStreamId(tuple.getSourceComponent(), tuple.getSourceStreamId());
    if (!_pending.containsKey(id)) {
      _pending.put(id, new HashMap<GlobalStreamId, Tuple>());
    }
    Map<GlobalStreamId, Tuple> parts = _pending.get(id);
    if (parts.containsKey(streamId))
      throw new RuntimeException("Received same side of single join twice");
    parts.put(streamId, tuple);
    if (parts.size() == _numSources) {
      _pending.remove(id);
      List<Object> joinResult = new ArrayList<Object>();
      for (String outField : _outFields) {
        GlobalStreamId loc = _fieldLocations.get(outField);
        joinResult.add(parts.get(loc).getValueByField(outField));
      }
      _collector.emit(new ArrayList<Tuple>(parts.values()), joinResult);

      for (Tuple part : parts.values()) {
        _collector.ack(part);
      }
    }
  }
  public ActionCallback restoreLastUiState() {
    final ActionCallback result = new ActionCallback(myPlaceInGrid2Cell.values().size());
    for (final GridCellImpl cell : myPlaceInGrid2Cell.values()) {
      cell.restoreLastUiState().notifyWhenDone(result);
    }

    return result;
  }
Esempio n. 16
0
 public FloatMatrix getParameters() {
   return MatrixUtil.toFlattenedFloat(
       getNumParameters(),
       binaryTransform.values().iterator(),
       binaryClassification.values().iterator(),
       binaryFloatTensors.values().iterator(),
       unaryClassification.values().iterator(),
       featureVectors.values().iterator());
 }
Esempio n. 17
0
  public void stop() {
    for (Manageable manageable : consumers.values()) {
      manageable.stop();
    }

    for (Manageable manageable : producers.values()) {
      manageable.stop();
    }
  }
Esempio n. 18
0
 public void setParameters(FloatMatrix params) {
   setParams(
       params,
       binaryTransform.values().iterator(),
       binaryClassification.values().iterator(),
       binaryFloatTensors.values().iterator(),
       unaryClassification.values().iterator(),
       featureVectors.values().iterator());
 }
  @Override
  public boolean isEmpty(SerializerProvider prov, Map<?, ?> value) {
    if (value.isEmpty()) {
      return true;
    }

    // 05-Nove-2015, tatu: Simple cases are cheap, but for recursive
    //   emptiness checking we actually need to see if values are empty as well.
    Object supp = _suppressableValue;
    if ((supp == null) && !_suppressNulls) {
      return false;
    }
    JsonSerializer<Object> valueSer = _valueSerializer;
    final boolean checkEmpty = (MARKER_FOR_EMPTY == supp);
    if (valueSer != null) {
      for (Object elemValue : value.values()) {
        if (elemValue == null) {
          if (_suppressNulls) {
            continue;
          }
          return false;
        }
        if (checkEmpty) {
          if (!valueSer.isEmpty(prov, elemValue)) {
            return false;
          }
        } else if ((supp == null) || !supp.equals(value)) {
          return false;
        }
      }
      return true;
    }
    // But if not statically known, try this:
    for (Object elemValue : value.values()) {
      if (elemValue == null) {
        if (_suppressNulls) {
          continue;
        }
        return false;
      }
      try {
        valueSer = _findSerializer(prov, elemValue);
      } catch (JsonMappingException e) { // Ugh... can not just throw as-is, so...
        // 05-Nov-2015, tatu: For now, probably best not to assume empty then
        return false;
      }
      if (checkEmpty) {
        if (!valueSer.isEmpty(prov, elemValue)) {
          return false;
        }
      } else if ((supp == null) || !supp.equals(value)) {
        return false;
      }
    }
    return true;
  }
 public CFAccFeeBuff[] readAllDerived(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "CFAccRamFee.readAllDerived";
   CFAccFeeBuff[] retList = new CFAccFeeBuff[dictByPKey.values().size()];
   Iterator<CFAccFeeBuff> iter = dictByPKey.values().iterator();
   int idx = 0;
   while (iter.hasNext()) {
     retList[idx++] = iter.next();
   }
   return (retList);
 }
 public CFBamISOCurrencyBuff[] readAllDerived(CFBamAuthorization Authorization) {
   final String S_ProcName = "CFBamRamISOCurrency.readAllDerived() ";
   CFBamISOCurrencyBuff[] retList = new CFBamISOCurrencyBuff[dictByPKey.values().size()];
   Iterator<CFBamISOCurrencyBuff> iter = dictByPKey.values().iterator();
   int idx = 0;
   while (iter.hasNext()) {
     retList[idx++] = iter.next();
   }
   return (retList);
 }
Esempio n. 22
0
 /**
  * Removes all effects from controllers and ends them appropriately Passive effect will not be
  * removed
  */
 public void removeAllEffects() {
   for (Effect effect : abnormalEffectMap.values()) {
     effect.endEffect();
   }
   abnormalEffectMap.clear();
   for (Effect effect : noshowEffects.values()) {
     effect.endEffect();
   }
   noshowEffects.clear();
 }
  /**
   * Populate cache with {@code 'facts'}, which in our case are {@link FactPurchase} objects.
   *
   * @param factCache Cache to populate.
   * @throws IgniteException If failed.
   */
  private static void populateFacts(Cache<Integer, FactPurchase> factCache) throws IgniteException {
    for (int i = 0; i < 100; i++) {
      int id = idGen++;

      DimStore store = rand(dataStore.values());
      DimProduct prod = rand(dataProduct.values());

      factCache.put(id, new FactPurchase(id, prod.getId(), store.getId(), (i + 1)));
    }
  }
Esempio n. 24
0
 public Collection<String> getRequiredFields() {
   Map<String, String> ret = Maps.newHashMap();
   if (indexes != null) {
     for (CIndex i : indexes.values()) {
       for (String key : i.getCompositeKeyList()) {
         ret.put(key, key);
       }
     }
   }
   return ret.values();
 }
 private BundleWiringDTO getBundleWiringDTO(BundleWiring wiring) {
   if (wiring == null) {
     return null;
   }
   BundleWiringDTO dto = new BundleWiringDTO();
   dto.bundle = wiring.getBundle().getBundleId();
   dto.root = getWiringId(wiring);
   dto.nodes = new HashSet<BundleWiringDTO.NodeDTO>(wiringnodes.values());
   dto.resources = new HashSet<BundleRevisionDTO>(resources.values());
   return dto;
 }
  public void findStudentResult(String name) {
    System.out.println("Student name:" + name);

    Map<Subject, Double> subjectDoubleMap = new HashMap<>();
    Map<Subject, Integer> subjectIntegerMap = new HashMap<>();

    /**
     * бежим по группам с типом результатов double и ищем студента если есть, то записываем в
     * subjectDoubleMap
     */
    for (Group<Double> indexDGroup : dGroups) {
      if (indexDGroup.getEvalByName(name) == null) {
        continue;
      } else {
        subjectDoubleMap.put(indexDGroup.getSubject(), indexDGroup.getEvalByName(name));
      }
    }
    /*
     * результируюзщий map не пустой, то выводим на экран
     *
     */
    if (!subjectDoubleMap.isEmpty()) {
      System.out.println(subjectDoubleMap);
      double max1 = Collections.max(subjectDoubleMap.values());

      for (Subject s : subjectDoubleMap.keySet()) {
        if (subjectDoubleMap.get(s) == max1) {
          System.out.println(s + ":" + max1);
        }
      }
    }

    /**
     * бежим по группам с типом результатов integer и ищем студента если есть, то записываем в
     * subjectDoubleMap
     */
    for (Group<Integer> indexIGroup : iGroups) {
      if (indexIGroup.getEvalByName(name) == null) {
        continue;
      } else {
        subjectIntegerMap.put(indexIGroup.getSubject(), indexIGroup.getEvalByName(name));
      }
    }
    if (!subjectIntegerMap.isEmpty()) {
      System.out.println(subjectIntegerMap);
      int max2 = Collections.max(subjectIntegerMap.values());
      for (Subject s : subjectIntegerMap.keySet()) {
        if (subjectIntegerMap.get(s) == max2) {
          System.out.println(s + ":" + max2);
        }
      }
    }
  }
 public boolean hasAssociationsFor(@NotNull T fileType) {
   if (myExtensionMappings.values().contains(fileType)
       || myExactFileNameMappings.values().contains(fileType)
       || myExactFileNameAnyCaseMappings.values().contains(fileType)) {
     return true;
   }
   for (Pair<FileNameMatcher, T> mapping : myMatchingMappings) {
     if (mapping.getSecond() == fileType) {
       return true;
     }
   }
   return false;
 }
 private String getCurrentVersion() {
   String version = extractNumericVersion(releaseProps.values());
   if (StringUtils.isBlank(version)) {
     version = extractNumericVersion(nextIntegProps.values());
   }
   if (StringUtils.isBlank(version)) {
     if (!releaseProps.values().isEmpty()) {
       version = releaseProps.values().iterator().next();
     } else if (!nextIntegProps.values().isEmpty()) {
       version = nextIntegProps.values().iterator().next();
     }
   }
   return version;
 }
	public void testPersistence() throws BundleException, InvalidSyntaxException {
		// get the system region
		Region systemRegion = digraph.getRegion(0);
		Map<String, Bundle> bundles = new HashMap<String, Bundle>();
		// create a disconnected test region for each test bundle
		for (String location : ALL) {
			Region testRegion = digraph.createRegion(location);
			bundles.put(location, bundleInstaller.installBundle(location, testRegion));
			// Import the system bundle from the systemRegion
			digraph.connect(testRegion, digraph.createRegionFilterBuilder().allow(RegionFilter.VISIBLE_BUNDLE_NAMESPACE, "(id=0)").build(), systemRegion);
			// must import Boolean services into systemRegion to test
			digraph.connect(systemRegion, digraph.createRegionFilterBuilder().allow(RegionFilter.VISIBLE_SERVICE_NAMESPACE, "(objectClass=java.lang.Boolean)").build(), testRegion);
		}

		bundleInstaller.resolveBundles(bundles.values().toArray(new Bundle[bundles.size()]));
		assertEquals(PP1, Bundle.RESOLVED, bundles.get(PP1).getState());
		assertEquals(SP1, Bundle.INSTALLED, bundles.get(SP1).getState());
		assertEquals(CP1, Bundle.RESOLVED, bundles.get(CP1).getState());
		assertEquals(PP2, Bundle.INSTALLED, bundles.get(PP2).getState());
		assertEquals(SP2, Bundle.INSTALLED, bundles.get(SP2).getState());
		assertEquals(CP2, Bundle.INSTALLED, bundles.get(CP2).getState());
		assertEquals(BC1, Bundle.INSTALLED, bundles.get(BC1).getState());
		assertEquals(SC1, Bundle.INSTALLED, bundles.get(SC1).getState());
		assertEquals(CC1, Bundle.INSTALLED, bundles.get(CC1).getState());

		regionBundle.stop();
		bundleInstaller.resolveBundles(bundles.values().toArray(new Bundle[bundles.size()]));
		assertEquals(PP1, Bundle.RESOLVED, bundles.get(PP1).getState());
		assertEquals(SP1, Bundle.RESOLVED, bundles.get(SP1).getState());
		assertEquals(CP1, Bundle.RESOLVED, bundles.get(CP1).getState());
		assertEquals(PP2, Bundle.RESOLVED, bundles.get(PP2).getState());
		assertEquals(SP2, Bundle.RESOLVED, bundles.get(SP2).getState());
		assertEquals(CP2, Bundle.RESOLVED, bundles.get(CP2).getState());
		assertEquals(BC1, Bundle.RESOLVED, bundles.get(BC1).getState());
		assertEquals(SC1, Bundle.RESOLVED, bundles.get(SC1).getState());
		assertEquals(CC1, Bundle.RESOLVED, bundles.get(CC1).getState());

		startRegionBundle();

		bundleInstaller.refreshPackages(bundles.values().toArray(new Bundle[bundles.size()]));
		assertEquals(PP1, Bundle.RESOLVED, bundles.get(PP1).getState());
		assertEquals(SP1, Bundle.INSTALLED, bundles.get(SP1).getState());
		assertEquals(CP1, Bundle.RESOLVED, bundles.get(CP1).getState());
		assertEquals(PP2, Bundle.INSTALLED, bundles.get(PP2).getState());
		assertEquals(SP2, Bundle.INSTALLED, bundles.get(SP2).getState());
		assertEquals(CP2, Bundle.INSTALLED, bundles.get(CP2).getState());
		assertEquals(BC1, Bundle.INSTALLED, bundles.get(BC1).getState());
		assertEquals(SC1, Bundle.INSTALLED, bundles.get(SC1).getState());
		assertEquals(CC1, Bundle.INSTALLED, bundles.get(CC1).getState());
	}
Esempio n. 30
0
 @NotNull
 private List<HighlightSeverity> getDefaultOrder() {
   Collection<SeverityBasedTextAttributes> values = myMap.values();
   List<HighlightSeverity> order =
       new ArrayList<HighlightSeverity>(STANDARD_SEVERITIES.size() + values.size());
   for (HighlightInfoType type : STANDARD_SEVERITIES.values()) {
     order.add(type.getSeverity(null));
   }
   for (SeverityBasedTextAttributes attributes : values) {
     order.add(attributes.getSeverity());
   }
   ContainerUtil.sort(order);
   return order;
 }