Пример #1
0
  // ## operation writeChemkinReactions(ReactionModel)
  // 10/26/07 gmagoon: changed to take temperature as parameter (it doesn't seem like this method is
  // currently used anywhere)
  public static String writeChemkinReactions(
      ReactionModel p_reactionModel, Temperature p_temperature) {
    // #[ operation writeChemkinReactions(ReactionModel)
    StringBuilder result = new StringBuilder();
    result.append("REACTIONS	KCAL/MOLE\n");
    CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel;

    LinkedHashSet all = cerm.getReactedReactionSet();

    HashSet hs = new HashSet();
    int numfor = 0;
    int numrev = 0;
    int numdup = 0;
    int numnorev = 0;
    for (Iterator iter = all.iterator(); iter.hasNext(); ) {
      Reaction rxn = (Reaction) iter.next();
      if (rxn.isForward()) {
        result.append(
            " "
                + rxn.toChemkinString(p_temperature)
                + "\n"); // 10/26/07 gmagoon: changed to avoid use of Global.temperature
        //	result.append(" " + rxn.toChemkinString(Global.temperature) + "\n");

      }
    }

    result.append("END\n");

    return result.toString();

    // #]
  }
Пример #2
0
 public void fireSimEvent() {
   SimEvent se = new SimEvent(this, entity.getTimeNow());
   for (Iterator<?> i = listeners.iterator(); i.hasNext(); ) {
     ((SimEventListener) i.next()).simEventOccurred(se);
   }
   entity.schedule("fireSimEvent", period);
 }
Пример #3
0
    private synchronized TaskAttemptId getAndRemove(int volumeId) {
      TaskAttemptId taskAttemptId = null;
      if (!unassignedTaskForEachVolume.containsKey(volumeId)) {
        if (volumeId > REMOTE) {
          diskVolumeLoads.remove(volumeId);
        }
        return taskAttemptId;
      }

      LinkedHashSet<TaskAttempt> list = unassignedTaskForEachVolume.get(volumeId);
      if (list != null && !list.isEmpty()) {
        TaskAttempt taskAttempt;
        synchronized (unassignedTaskForEachVolume) {
          Iterator<TaskAttempt> iterator = list.iterator();
          taskAttempt = iterator.next();
          iterator.remove();
        }

        taskAttemptId = taskAttempt.getId();
        for (DataLocation location : taskAttempt.getTask().getDataLocations()) {
          HostVolumeMapping volumeMapping =
              scheduledRequests.leafTaskHostMapping.get(location.getHost());
          if (volumeMapping != null) {
            volumeMapping.removeTaskAttempt(location.getVolumeId(), taskAttempt);
          }
        }

        increaseConcurrency(volumeId);
      }

      return taskAttemptId;
    }
Пример #4
0
 public static ArrayList<Integer> roll(LinkedHashSet<Dice> dice) {
   ArrayList<Integer> ret = new ArrayList<Integer>();
   Iterator<Dice> it = dice.iterator();
   while (it.hasNext()) {
     ret.add(it.next().roll());
   }
   return ret;
 }
Пример #5
0
  /**
   * Returns an array containing all installed providers that satisfy the specified* selection
   * criteria, or null if no such providers have been installed. The returned providers are ordered
   * according to their <a href= "#insertProviderAt(java.security.Provider, int)">preference
   * order</a>.
   *
   * <p>The selection criteria are represented by a map. Each map entry represents a selection
   * criterion. A provider is selected iff it satisfies all selection criteria. The key for any
   * entry in such a map must be in one of the following two formats:
   *
   * <ul>
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type></i>
   *       <p>The cryptographic service name must not contain any dots.
   *       <p>The value associated with the key must be an empty string.
   *       <p>A provider satisfies this selection criterion iff the provider implements the
   *       specified algorithm or type for the specified cryptographic service.
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type> &lt;attribute_name></i>
   *       <p>The cryptographic service name must not contain any dots. There must be one or more
   *       space charaters between the <i>&lt;algorithm_or_type></i> and the
   *       <i>&lt;attribute_name></i>.
   *       <p>The value associated with the key must be a non-empty string. A provider satisfies
   *       this selection criterion iff the provider implements the specified algorithm or type for
   *       the specified cryptographic service and its implementation meets the constraint expressed
   *       by the specified attribute name/value pair.
   * </ul>
   *
   * <p>See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java
   * Cryptogaphy Architecture API Specification &amp; Reference </a> for information about standard
   * cryptographic service names, standard algorithm names and standard attribute names.
   *
   * @param filter the criteria for selecting providers. The filter is case-insensitive.
   * @return all the installed providers that satisfy the selection criteria, or null if no such
   *     providers have been installed.
   * @throws InvalidParameterException if the filter is not in the required format
   * @throws NullPointerException if filter is null
   * @see #getProviders(java.lang.String)
   */
  public static Provider[] getProviders(Map<String, String> filter) {
    // Get all installed providers first.
    // Then only return those providers who satisfy the selection criteria.
    Provider[] allProviders = Security.getProviders();
    Set keySet = filter.keySet();
    LinkedHashSet candidates = new LinkedHashSet(5);

    // Returns all installed providers
    // if the selection criteria is null.
    if ((keySet == null) || (allProviders == null)) {
      return allProviders;
    }

    boolean firstSearch = true;

    // For each selection criterion, remove providers
    // which don't satisfy the criterion from the candidate set.
    for (Iterator ite = keySet.iterator(); ite.hasNext(); ) {
      String key = (String) ite.next();
      String value = (String) filter.get(key);

      LinkedHashSet newCandidates = getAllQualifyingCandidates(key, value, allProviders);
      if (firstSearch) {
        candidates = newCandidates;
        firstSearch = false;
      }

      if ((newCandidates != null) && !newCandidates.isEmpty()) {
        // For each provider in the candidates set, if it
        // isn't in the newCandidate set, we should remove
        // it from the candidate set.
        for (Iterator cansIte = candidates.iterator(); cansIte.hasNext(); ) {
          Provider prov = (Provider) cansIte.next();
          if (!newCandidates.contains(prov)) {
            cansIte.remove();
          }
        }
      } else {
        candidates = null;
        break;
      }
    }

    if ((candidates == null) || (candidates.isEmpty())) return null;

    Object[] candidatesArray = candidates.toArray();
    Provider[] result = new Provider[candidatesArray.length];

    for (int i = 0; i < result.length; i++) {
      result[i] = (Provider) candidatesArray[i];
    }

    return result;
  }
 private void A()
 {
   c.notifyDataSetChanged();
   Iterator localIterator = K.iterator();
   String str2 = "";
   for (String str1 = ""; localIterator.hasNext(); str1 = ", ")
   {
     ajy localajy = (ajy)localIterator.next();
     str2 = str2 + str1 + mDisplayName;
   }
   ((SendToBottomPanelView)M.a()).setText(str2);
 }
 @Override
 public void calcData(final DataKey key, final DataSink sink) {
   if (key.equals(LangDataKeys.PSI_ELEMENT)) {
     if (mySelectedElements != null && !mySelectedElements.isEmpty()) {
       T selectedElement = mySelectedElements.iterator().next();
       if (selectedElement instanceof ClassMemberWithElement) {
         sink.put(
             LangDataKeys.PSI_ELEMENT, ((ClassMemberWithElement) selectedElement).getElement());
       }
     }
   }
 }
Пример #8
0
 // ## operation setReactantTree(LinkedHashSet)
 public void setReactantTree(LinkedHashSet p_treeSet) {
   // #[ operation setReactantTree(LinkedHashSet)
   if (p_treeSet == null) throw new InvalidReactantTreeException();
   int size = p_treeSet.size();
   if (size == 0) throw new InvalidReactantTreeException();
   Iterator iter = p_treeSet.iterator();
   while (iter.hasNext()) {
     HierarchyTree tree = (HierarchyTree) iter.next();
     addReactantTree(tree);
   }
   return;
   // #]
 }
Пример #9
0
  // constructor
  public SeqGraphXcons(
      SeqGraph graph,
      LinkedHashSet<SeqNode> startNodes,
      LinkedHashSet<SeqNode> stopNodes,
      boolean stopAtFFTs)
      throws Xcept {
    this.graph = graph;
    this.startNodes = startNodes;
    this.stopNodes = stopNodes;
    this.stopAtFFTs = stopAtFFTs;

    System.err.println("SeqGraphXCons stopAtFFTs=" + stopAtFFTs);
    nodeDests = new Hashtable<SeqNode, LinkedHashSet<SeqNode>>();
    Iterator<SeqNode> ns = startNodes.iterator();
    while (ns.hasNext()) {
      SeqNode n = ns.next();
      SeqPhase p = graph.getPhase(n);
      initNodeDests(p, n);
    }
    System.err.println("  nodeDests=" + nodeDests);
  }
Пример #10
0
 /*
  * Instruct the build manager that this project is involved in a cycle and
  * needs to propagate structural changes to the other projects in the cycle.
  */
 void mustPropagateStructuralChanges() {
   LinkedHashSet cycleParticipants = new LinkedHashSet(3);
   this.javaProject.updateCycleParticipants(
       new ArrayList(), cycleParticipants, this.workspaceRoot, new HashSet(3), null);
   IPath currentPath = this.javaProject.getPath();
   Iterator i = cycleParticipants.iterator();
   while (i.hasNext()) {
     IPath participantPath = (IPath) i.next();
     if (participantPath != currentPath) {
       IProject project = this.workspaceRoot.getProject(participantPath.segment(0));
       if (hasBeenBuilt(project)) {
         if (DEBUG)
           System.out.println(
               "JavaBuilder: Requesting another build iteration since cycle participant "
                   + project.getName() // $NON-NLS-1$
                   + " has not yet seen some structural changes"); //$NON-NLS-1$
         needRebuild();
         return;
       }
     }
   }
 }
  @Nullable
  static String filterBadPlugins(
      List<? extends IdeaPluginDescriptor> result, final Map<String, String> disabledPluginNames) {
    final Map<PluginId, IdeaPluginDescriptor> idToDescriptorMap =
        new HashMap<PluginId, IdeaPluginDescriptor>();
    final StringBuffer message = new StringBuffer();
    boolean pluginsWithoutIdFound = false;
    for (Iterator<? extends IdeaPluginDescriptor> it = result.iterator(); it.hasNext(); ) {
      final IdeaPluginDescriptor descriptor = it.next();
      final PluginId id = descriptor.getPluginId();
      if (id == null) {
        pluginsWithoutIdFound = true;
      }
      if (idToDescriptorMap.containsKey(id)) {
        message.append("<br>");
        message.append(IdeBundle.message("message.duplicate.plugin.id"));
        message.append(id);
        it.remove();
      } else if (descriptor.isEnabled()) {
        idToDescriptorMap.put(id, descriptor);
      }
    }
    addModulesAsDependents(idToDescriptorMap);
    final List<String> disabledPluginIds = new ArrayList<String>();
    final LinkedHashSet<String> faultyDescriptors = new LinkedHashSet<String>();
    for (final Iterator<? extends IdeaPluginDescriptor> it = result.iterator(); it.hasNext(); ) {
      final IdeaPluginDescriptor pluginDescriptor = it.next();
      checkDependants(
          pluginDescriptor,
          new Function<PluginId, IdeaPluginDescriptor>() {
            @Override
            public IdeaPluginDescriptor fun(final PluginId pluginId) {
              return idToDescriptorMap.get(pluginId);
            }
          },
          new Condition<PluginId>() {
            @Override
            public boolean value(final PluginId pluginId) {
              if (!idToDescriptorMap.containsKey(pluginId)) {
                pluginDescriptor.setEnabled(false);
                if (!pluginId.getIdString().startsWith(MODULE_DEPENDENCY_PREFIX)) {
                  faultyDescriptors.add(pluginId.getIdString());
                  disabledPluginIds.add(pluginDescriptor.getPluginId().getIdString());
                  message.append("<br>");
                  final String name = pluginDescriptor.getName();
                  final IdeaPluginDescriptor descriptor = idToDescriptorMap.get(pluginId);
                  String pluginName;
                  if (descriptor == null) {
                    pluginName = pluginId.getIdString();
                    if (disabledPluginNames.containsKey(pluginName)) {
                      pluginName = disabledPluginNames.get(pluginName);
                    }
                  } else {
                    pluginName = descriptor.getName();
                  }

                  message.append(
                      getDisabledPlugins().contains(pluginId.getIdString())
                          ? IdeBundle.message("error.required.plugin.disabled", name, pluginName)
                          : IdeBundle.message(
                              "error.required.plugin.not.installed", name, pluginName));
                }
                it.remove();
                return false;
              }
              return true;
            }
          });
    }
    if (!disabledPluginIds.isEmpty()) {
      myPlugins2Disable = disabledPluginIds;
      myPlugins2Enable = faultyDescriptors;
      message.append("<br>");
      message.append("<br>").append("<a href=\"" + DISABLE + "\">Disable ");
      if (disabledPluginIds.size() == 1) {
        final PluginId pluginId2Disable = PluginId.getId(disabledPluginIds.iterator().next());
        message.append(
            idToDescriptorMap.containsKey(pluginId2Disable)
                ? idToDescriptorMap.get(pluginId2Disable).getName()
                : pluginId2Disable.getIdString());
      } else {
        message.append("not loaded plugins");
      }
      message.append("</a>");
      boolean possibleToEnable = true;
      for (String descriptor : faultyDescriptors) {
        if (disabledPluginNames.get(descriptor) == null) {
          possibleToEnable = false;
          break;
        }
      }
      if (possibleToEnable) {
        message
            .append("<br>")
            .append("<a href=\"" + ENABLE + "\">Enable ")
            .append(
                faultyDescriptors.size() == 1
                    ? disabledPluginNames.get(faultyDescriptors.iterator().next())
                    : " all necessary plugins")
            .append("</a>");
      }
      message.append("<br>").append("<a href=\"" + EDIT + "\">Open plugin manager</a>");
    }
    if (pluginsWithoutIdFound) {
      message.append("<br>");
      message.append(IdeBundle.message("error.plugins.without.id.found"));
    }
    if (message.length() > 0) {
      message.insert(0, IdeBundle.message("error.problems.found.loading.plugins"));
      return message.toString();
    }
    return null;
  }
Пример #12
0
  @Transactional
  public DayGrid updateDayGid(DayGrid dayGrid, String profile) throws ParseException {

    Set<EmplacementDTO> blocs = dayGrid.getBlocs();
    if (blocs != null) {
      for (Iterator<EmplacementDTO> iterator = blocs.iterator(); iterator.hasNext(); ) {
        EmplacementDTO emplacementDTO = iterator.next();
        Set<RubriqueDTO> rubriqueDTOSet = emplacementDTO.getRubrique();
        if (rubriqueDTOSet != null) {
          for (Iterator<RubriqueDTO> rubriqueDTOIterator = rubriqueDTOSet.iterator();
              rubriqueDTOIterator.hasNext(); ) {
            RubriqueDTO rubriqueDTO = rubriqueDTOIterator.next();
            rubriqueLoggingService.updateEmplacementRubriqueForDay(
                emplacementDTO.getId(),
                emplacementDTO.getName(),
                emplacementDTO.getPosition(),
                rubriqueDTO.getId(),
                profile,
                dayGrid.getId());

            LinkedHashSet<CommunicationGroupDTO> communicationGroups =
                rubriqueDTO.getCommunicationGroups();
            for (Iterator<CommunicationGroupDTO> communicationGroupDTOIterator =
                    communicationGroups.iterator();
                communicationGroupDTOIterator.hasNext(); ) {
              CommunicationGroupDTO communicationGroupDTO = communicationGroupDTOIterator.next();
              LinkedHashSet<CommunicationDTO> communicationDTOs =
                  communicationGroupDTO.getCommunications();
              if (communicationDTOs != null && communicationDTOs.size() > 0) {
                List<String> communicationIdsToDeactivate = Lists.newArrayList();
                List<String> communicationIdsToActivate = Lists.newArrayList();
                for (Iterator<CommunicationDTO> communicationDTOIterator =
                        communicationDTOs.iterator();
                    communicationDTOIterator.hasNext(); ) {
                  CommunicationDTO communicationDTO = communicationDTOIterator.next();
                  if (isToday(dayGrid.getDate())) {
                    if (communicationDTO.isDeactivated()
                        && !communicationLoggingService.isDeactivatedCommunicationLogging(
                            communicationDTO.getCommunicationLoggingId())) {
                      communicationIdsToDeactivate.add(communicationDTO.getIdArrowCommunication());
                    }
                    if (!communicationDTO.isDeactivated()
                        && communicationLoggingService.isDeactivatedCommunicationLogging(
                            communicationDTO.getCommunicationLoggingId())) {
                      communicationIdsToActivate.add(communicationDTO.getIdArrowCommunication());
                    }
                  }
                  // update communicationLogging
                  communicationLoggingService.updateCommunicationLoggingForCommunicationAndDay(
                      communicationDTO.getIdCommunication(),
                      dayGrid.getId(),
                      communicationDTO.getPriority(),
                      communicationGroupDTO.getId(),
                      communicationGroupDTO.getLabel(),
                      communicationDTO.getNbAffichageMax(),
                      communicationDTO.getNbJourAffichageMax(),
                      communicationDTO.getNbClicMax(),
                      communicationDTO.getNbJourClicMax(),
                      communicationDTO.isDeactivated());
                }
                if (isToday(dayGrid.getDate())) {
                  if (CollectionUtils.isNotEmpty(communicationIdsToDeactivate)) {
                    deactivateCommunicationsInstantaneously(
                        dayGrid.getDate(), communicationIdsToDeactivate);
                  }
                  if (CollectionUtils.isNotEmpty(communicationIdsToActivate)) {
                    activateCommunicationsInstantaneously(
                        dayGrid.getDate(), communicationIdsToActivate);
                  }
                }
              }
            }
          }
        }
      }
    }

    return dayGrid;
  }
Пример #13
0
  @Transactional
  public DayGrid getDayGridForDay(
      Date date, Long siteId, Long pageId, String profile, User user, boolean future)
      throws ExecutionException { // , Map<Long,Set<AnimationDTO>> validAnimationsByRubriques) {
    logger.debug(
        "getDayGridForDay for date {}, site {}, page {} and profile {}",
        date,
        siteId,
        pageId,
        profile);
    Day day = periodService.getDay(date);

    List<CommunicationGroup> communicationGroups = arrowService.getCommunicationGroups();

    // recuperer liste des emplacements avec rubriques attaches pour le profile
    // commencer par chercher la liste des rubriques, et voir si y a des rubriqueLogging pour ce
    // jour et ce profil
    // si la liste est vide créer les rubriqueLogging avec les emplaceemnts par défaut (le test pour
    // création est fait dans le service)
    LinkedHashSet<RubriqueLogging> emplacementsRubriqueForThisDay =
        rubriqueLoggingService.getRubriqueLoggingForSiteProfileAndDay(
            siteId, pageId, profile, day.getId());

    LinkedHashSet<EmplacementDTO> blocs = new LinkedHashSet<>();
    for (Iterator<RubriqueLogging> iterator = emplacementsRubriqueForThisDay.iterator();
        iterator.hasNext(); ) {
      EmplacementDTO emplacementDTO = new EmplacementDTO();

      RubriqueLogging rubriqueLogging = iterator.next();
      emplacementDTO.setId(rubriqueLogging.getIdEmplacement());
      emplacementDTO.setName(rubriqueLogging.getEmplacement());
      emplacementDTO.setPosition(rubriqueLogging.getPosition());
      LinkedHashSet<RubriqueDTO> rubriquesDTO = new LinkedHashSet<>();
      Rubrique rubrique = neo4jOperations.fetch(rubriqueLogging.getRubrique());

      // NEW CODE
      LinkedHashSet<CommunicationQueryResult> communications =
          dayRepository.findCommunicationForGridDayAndRubrique(
              rubrique.getId(), day.getId(), profile, !future);
      LinkedHashMap<String, LinkedHashSet<CommunicationDTO>> tempCommunicationGroup =
          new LinkedHashMap<>();
      for (Iterator<CommunicationQueryResult> communicationQueryResultIterator =
              communications.iterator();
          communicationQueryResultIterator.hasNext(); ) {
        CommunicationQueryResult communicationQueryResult = communicationQueryResultIterator.next();
        CommunicationDTO communicationDTO = communicationDTOAdapter.adapt(communicationQueryResult);
        LinkedHashSet<CommunicationDTO> communicationDTOListForThisGroup =
            tempCommunicationGroup.get(communicationDTO.getCommunicationGroupId());
        if (communicationDTOListForThisGroup == null) {
          communicationDTOListForThisGroup = new LinkedHashSet<>();
        }
        communicationDTOListForThisGroup.add(communicationDTO);
        tempCommunicationGroup.put(
            communicationDTO.getCommunicationGroupId(), communicationDTOListForThisGroup);
      }

      LinkedHashSet<CommunicationGroupDTO> communicationGroupDTOs = new LinkedHashSet<>();

      for (Iterator<CommunicationGroup> communicationGroupsIterator =
              communicationGroups.iterator();
          communicationGroupsIterator.hasNext(); ) {
        CommunicationGroup communicationGroup = communicationGroupsIterator.next();
        LinkedHashSet<CommunicationDTO> communicationDTOListForThisGroup =
            tempCommunicationGroup.get(communicationGroup.getId());
        if (communicationDTOListForThisGroup == null) {
          communicationDTOListForThisGroup = new LinkedHashSet<>();
        }
        communicationGroupDTOs.add(
            new CommunicationGroupDTO(
                communicationGroup.getId(),
                communicationGroup.getLabel(),
                communicationDTOListForThisGroup));
      }

      // END NEW CODE

      /*Set<AnimationDTO> animations = validAnimationsByRubriques.get(rubrique.getId());
      // rubrique.getAnimations();
      Set<AnimationDTO> animationsDTO = new LinkedHashSet<>();
      for (Iterator<AnimationDTO> animationIterator = animations.iterator(); animationIterator.hasNext(); ) {
          AnimationDTO animation = animationIterator.next();
          //vérifier si l'animation est valide ce jour là
          Calendar endDateCalendar = GregorianCalendar.getInstance();
          endDateCalendar.setTime( animation.getDateFin());
          endDateCalendar.add(GregorianCalendar.DAY_OF_YEAR, 1);

          Interval interval = new Interval( animation.getDateDebut().getTime(), endDateCalendar.getTime().getTime() );
          boolean intervalContainsThisDay = interval.contains( date.getTime() );
          if(intervalContainsThisDay){
              //mettre à jour les créas pour ce jour là
              animationsDTO.add(animation);
          }
      }*/
      RubriqueDTO rubriqueDTO =
          new RubriqueDTO(
              rubrique.getId(),
              rubrique.getNom(),
              rubrique.getManagedByCooper(),
              communicationGroupDTOs);
      rubriquesDTO.add(rubriqueDTO);
      emplacementDTO.setRubrique(rubriquesDTO);
      blocs.add(emplacementDTO);
    }
    DayGrid dayGrid = new DayGrid(day.getId(), day.getName(), blocs);

    String formattedDate = new SimpleDateFormat(Day.dateFormat).format(date);

    DayGridLock lockForDayAndProfile =
        gridLockManager.getLockStatusForDayAndProfile(siteId, pageId, formattedDate, profile, user);
    dayGrid.setDayGridLockDTO(new DayGridLockDTO(lockForDayAndProfile, user));

    return dayGrid;
  }
Пример #14
0
 @Override
 public Iterator<ReferenceInfo> iterator() {
   return columns.iterator();
 }