/**
   * Notifies this <tt>Conference</tt> that the ordered list of <tt>Endpoint</tt>s of {@link
   * #speechActivity} i.e. the dominant speaker history has changed.
   *
   * <p>This instance notifies the video <tt>Channel</tt>s about the change so that they may update
   * their last-n lists and report to this instance which <tt>Endpoint</tt>s are to be asked for
   * video keyframes.
   */
  private void speechActivityEndpointsChanged() {
    List<Endpoint> endpoints = null;

    for (Content content : getContents()) {
      if (MediaType.VIDEO.equals(content.getMediaType())) {
        Set<Endpoint> endpointsToAskForKeyframes = null;

        endpoints = speechActivity.getEndpoints();
        for (Channel channel : content.getChannels()) {
          if (!(channel instanceof RtpChannel)) continue;

          RtpChannel rtpChannel = (RtpChannel) channel;
          List<Endpoint> channelEndpointsToAskForKeyframes =
              rtpChannel.speechActivityEndpointsChanged(endpoints);

          if ((channelEndpointsToAskForKeyframes != null)
              && !channelEndpointsToAskForKeyframes.isEmpty()) {
            if (endpointsToAskForKeyframes == null) {
              endpointsToAskForKeyframes = new HashSet<>();
            }
            endpointsToAskForKeyframes.addAll(channelEndpointsToAskForKeyframes);
          }
        }

        if ((endpointsToAskForKeyframes != null) && !endpointsToAskForKeyframes.isEmpty()) {
          content.askForKeyframes(endpointsToAskForKeyframes);
        }
      }
    }
  }
Exemplo n.º 2
0
  private void checkStartup(
      Map<String, ServiceData> map,
      List<ServiceData> start,
      ServiceData sd,
      Set<ServiceData> cyclic) {
    if (sd.after.isEmpty() || start.contains(sd)) return;

    if (cyclic.contains(sd)) {
      reporter.error("Cyclic dependency for " + sd.name);
      return;
    }

    cyclic.add(sd);

    for (String dependsOn : sd.after) {
      if (dependsOn.equals("boot")) continue;

      ServiceData deps = map.get(dependsOn);
      if (deps == null) {
        reporter.error("No such service " + dependsOn + " but " + sd.name + " depends on it");
      } else {
        checkStartup(map, start, deps, cyclic);
      }
    }
    start.add(sd);
  }
Exemplo n.º 3
0
  public double evalBasisState(ArrayList state, double wb1, double wb2) {

    int sum_basis_1 = 0;
    int sum_basis_2 = 0;

    // TODO: Code to get connection links... use current state to get status
    // System.out.print(", Eval: " + state);
    Action a = (Action) _mdp._hmName2Action.get("noreboot");
    for (int c = 0; c < (_nVars << 1); c++) {
      Object cur_assign = state.get(c);
      if (cur_assign instanceof Boolean && ((Boolean) cur_assign).booleanValue()) {

        sum_basis_1++;

        // System.out.println(a._tmID2DD);
        int nonprime_id = c + 1;
        int prime_id = nonprime_id - _nVars;
        Object DD = a._tmID2DD.get(new Integer(prime_id));
        Set IDs = _mdp._context.getGIDs(DD);
        // System.out.print(IDs + ": ");
        Iterator it = IDs.iterator();
        // System.out.print("[" + prime_id + " - ");
        while (it.hasNext()) {
          int c_id = ((Integer) it.next()).intValue() - 1; // nonprime array index
          if (c_id < _nVars || c_id == c) { // Skip prime/np this var
            continue;
          }
          // System.out.print(c_id + " ");
          Object c_id_assign = state.get(c_id);
          if (c_id_assign instanceof Boolean && ((Boolean) c_id_assign).booleanValue()) {
            sum_basis_2++;
            break;
          }
        }
        // System.out.println("]");
      }
    }
    double val = wb1 * sum_basis_1 + wb2 * sum_basis_2;
    // System.out.println(state + ", b1: " + sum_basis_1 +
    //		   ", b2: " + sum_basis_2 + ", total: " +
    //		   _mdp._df.format(val));

    return val;
  }
Exemplo n.º 4
0
 @Override
 public Variable resolveVariable(org.exist.dom.QName qname) throws XPathException {
   Variable var = super.resolveVariable(qname);
   if (var == null) {
     requiredVariables.add(
         new QName(qname.getNamespaceURI(), qname.getLocalName(), qname.getPrefix()));
     var = new VariableImpl(qname);
   }
   return var;
 }
Exemplo n.º 5
0
 @Override
 public UserDefinedFunction resolveFunction(org.exist.dom.QName qname, int argCount)
     throws XPathException {
   UserDefinedFunction func = super.resolveFunction(qname, argCount);
   if (func == null) {
     requiredFunctions.add(
         new QName(qname.getNamespaceURI(), qname.getLocalName(), qname.getPrefix()));
     func =
         new UserDefinedFunction(
             this,
             new FunctionSignature(
                 qname,
                 null,
                 new SequenceType(Type.ITEM, org.exist.xquery.Cardinality.ZERO_OR_MORE),
                 true));
     func.setFunctionBody(new SequenceConstructor(this));
   }
   return func;
 }
Exemplo n.º 6
0
  /**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if business logic throws an exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    MessageResources messages = getResources(request);

    // save errors
    ActionMessages errors = new ActionMessages();

    // START check for login (security)
    if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) {
      return (mapping.findForward("welcome"));
    }
    // END check for login (security)

    // START get id of current project from either request, attribute, or cookie
    // id of project from request
    String projectId = null;
    projectId = request.getParameter("projectViewId");

    // check attribute in request
    if (projectId == null) {
      projectId = (String) request.getAttribute("projectViewId");
    }

    // id of project from cookie
    if (projectId == null) {
      projectId = StandardCode.getInstance().getCookie("projectViewId", request.getCookies());
    }

    // default project to last if not in request or cookie
    if (projectId == null) {
      List results = ProjectService.getInstance().getProjectList();

      ListIterator iterScroll = null;
      for (iterScroll = results.listIterator(); iterScroll.hasNext(); iterScroll.next()) {}
      iterScroll.previous();
      Project p = (Project) iterScroll.next();
      projectId = String.valueOf(p.getProjectId());
    }

    Integer id = Integer.valueOf(projectId);

    // END get id of current project from either request, attribute, or cookie

    // get project to edit
    Project p = ProjectService.getInstance().getSingleProject(id);

    // get this project's sources
    Set sources = p.getSourceDocs();

    // for each source add each sources' Tasks
    List totalLinTasks = new ArrayList();

    // for each source
    for (Iterator sourceIter = sources.iterator(); sourceIter.hasNext(); ) {
      SourceDoc sd = (SourceDoc) sourceIter.next();

      // for each target of this source
      for (Iterator linTargetIter = sd.getTargetDocs().iterator(); linTargetIter.hasNext(); ) {
        TargetDoc td = (TargetDoc) linTargetIter.next();

        // for each lin Task of this target
        for (Iterator linTaskIter = td.getLinTasks().iterator(); linTaskIter.hasNext(); ) {
          LinTask lt = (LinTask) linTaskIter.next();
          if (lt.getPersonName() != null
              && lt.getDueDateDate() != null
              && (lt.getTaskName().equalsIgnoreCase("Translation")
                  || lt.getTaskName().equalsIgnoreCase("Editing")
                  || lt.getTaskName().trim().equalsIgnoreCase("Proofreading")
                  || lt.getTaskName().equalsIgnoreCase("Proofreading / Linguistic QA"))) {
            totalLinTasks.add(lt);
          }
          System.out.println(
              sd.getLanguage() + "--------" + td.getLanguage() + "---------" + lt.getTaskName());
        }
      }
    }

    // Sort by task (orderNum), then source (language), then target (language)
    Collections.sort(totalLinTasks, CompareTaskLin.getInstance());
    Collections.sort(totalLinTasks, CompareTaskLanguages.getInstance());

    // array for display in jsp
    LinTask[] linTasksArray = (LinTask[]) totalLinTasks.toArray(new LinTask[0]);

    for (int i = 0; i < totalLinTasks.size(); i++) {
      request.setAttribute(projectId, log);
    }

    // place all Tasks for this project into the form for display
    DynaValidatorForm qvg = (DynaValidatorForm) form;

    // HERE down is standard and does not need to change when adding task blocks
    // place this project into request for further display in jsp page
    request.setAttribute("project", p);

    // add this project id to cookies; this will remember the last project
    response.addCookie(StandardCode.getInstance().setCookie("projectViewId", projectId));

    // add tab location to cookies; this will remember which tab we are at
    response.addCookie(StandardCode.getInstance().setCookie("projectViewTab", "Team"));

    // an update of totals may be required

    // Forward control to the specified success URI
    return (mapping.findForward("Success"));
  }
Exemplo n.º 7
0
  public static Object element(Object arg, ExecutionContext context)
      throws FunctionDomainException, TypeMismatchException {
    if (arg == null || arg == QueryService.UNDEFINED) return QueryService.UNDEFINED;

    if (arg instanceof Collection) {
      Collection c = (Collection) arg;
      // for remote distinct queries, the result of sub query could contain a
      // mix of String and PdxString which could be duplicates, so convert all
      // PdxStrings to String
      if (context.isDistinct() && ((DefaultQuery) context.getQuery()).isRemoteQuery()) {
        Set tempResults = new HashSet();
        for (Object o : c) {
          if (o instanceof PdxString) {
            o = ((PdxString) o).toString();
          }
          tempResults.add(o);
        }
        c.clear();
        c.addAll(tempResults);
        tempResults = null;
      }
      checkSingleton(c.size());
      return c.iterator().next();
    }

    // not a Collection, must be an array
    Class clazz = arg.getClass();
    if (!clazz.isArray())
      throw new TypeMismatchException(
          LocalizedStrings.Functions_THE_ELEMENT_FUNCTION_CANNOT_BE_APPLIED_TO_AN_OBJECT_OF_TYPE_0
              .toLocalizedString(clazz.getName()));

    // handle arrays
    if (arg instanceof Object[]) {
      Object[] a = (Object[]) arg;
      if (((DefaultQuery) context.getQuery()).isRemoteQuery() && context.isDistinct()) {
        for (int i = 0; i < a.length; i++) {
          if (a[i] instanceof PdxString) {
            a[i] = ((PdxString) a[i]).toString();
          }
        }
      }
      checkSingleton(a.length);
      return a[0];
    }

    if (arg instanceof int[]) {
      int[] a = (int[]) arg;
      checkSingleton(a.length);
      return Integer.valueOf(a[0]);
    }

    if (arg instanceof long[]) {
      long[] a = (long[]) arg;
      checkSingleton(a.length);
      return Long.valueOf(a[0]);
    }

    if (arg instanceof boolean[]) {
      boolean[] a = (boolean[]) arg;
      checkSingleton(a.length);
      return Boolean.valueOf(a[0]);
    }

    if (arg instanceof byte[]) {
      byte[] a = (byte[]) arg;
      checkSingleton(a.length);
      return Byte.valueOf(a[0]);
    }

    if (arg instanceof char[]) {
      char[] a = (char[]) arg;
      checkSingleton(a.length);
      return new Character(a[0]);
    }

    if (arg instanceof double[]) {
      double[] a = (double[]) arg;
      checkSingleton(a.length);
      return Double.valueOf(a[0]);
    }

    if (arg instanceof float[]) {
      float[] a = (float[]) arg;
      checkSingleton(a.length);
      return new Float(a[0]);
    }

    if (arg instanceof short[]) {
      short[] a = (short[]) arg;
      checkSingleton(a.length);
      return new Short(a[0]);
    }

    // did I miss something?
    throw new TypeMismatchException(
        LocalizedStrings.Functions_THE_ELEMENT_FUNCTION_CANNOT_BE_APPLIED_TO_AN_OBJECT_OF_TYPE_0
            .toLocalizedString(clazz.getName()));
  }
  /**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if business logic throws an exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    MessageResources messages = getResources(request);

    // save errors
    ActionMessages errors = new ActionMessages();

    // START check for login (security)
    if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) {
      return (mapping.findForward("welcome"));
    }
    // END check for login (security)

    // values for adding a new target Doc
    DynaValidatorForm qvgate1 = (DynaValidatorForm) form;

    String[] targets = (String[]) qvgate1.get("targets");
    String all = (String) qvgate1.get("all"); // the all languages box
    String engPrelim = (String) qvgate1.get("engPrelim");
    String engOther = (String) qvgate1.get("engOther");
    String engVerification = (String) qvgate1.get("engVerification");
    String engQA = (String) qvgate1.get("engQA");
    String engPrep = (String) qvgate1.get("engPrep");
    String engFunct = (String) qvgate1.get("engFunct");
    String engEng = (String) qvgate1.get("engEng");
    String engFinalQA = (String) qvgate1.get("engFinalQA");
    String engFinal = (String) qvgate1.get("engFinal");
    String eng0 = (String) (qvgate1.get("eng0"));
    String eng1 = (String) (qvgate1.get("eng1"));
    String eng2 = (String) (qvgate1.get("eng2"));
    String eng3 = (String) (qvgate1.get("eng3"));
    String eng4 = (String) (qvgate1.get("eng4"));
    String eng5 = (String) (qvgate1.get("eng5"));
    String eng6 = (String) (qvgate1.get("eng6"));
    String eng7 = (String) (qvgate1.get("eng7"));
    String eng8 = (String) (qvgate1.get("eng8"));
    String[] engTaskOptions = ProjectService.getInstance().getEngTaskOptions();

    // get the user's chosen source array for later use in case new target "new" needs to be created
    HttpSession session = request.getSession(false);
    SourceDoc[] sources = (SourceDoc[]) session.getAttribute("sourceArray");

    if (!all.equals("on")) { // if specific to only a few targets
      // for each target, add the new target to db and each target's new engineering tasks selected
      // from form
      for (int i = 0; i < targets.length; i++) {
        Set engTasks = new HashSet(); // list of new engTasks

        // need target doc and source doc to add tasks to it
        TargetDoc td = ProjectService.getInstance().getSingleTargetDoc(Integer.valueOf(targets[i]));
        SourceDoc sd = td.getSourceDoc();

        if (eng1.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[1 - 1]);
          et.setOrderNum(new Integer(1));
          engTasks.add(et);
        }

        if (eng2.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[2 - 1]);
          et.setOrderNum(new Integer(2));
          engTasks.add(et);
        }

        if (eng3.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[3 - 1]);
          et.setOrderNum(new Integer(3));
          engTasks.add(et);
        }

        if (eng4.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[4 - 1]);
          et.setOrderNum(new Integer(4));
          engTasks.add(et);
        }

        if (eng5.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[5 - 1]);
          et.setOrderNum(new Integer(5));
          engTasks.add(et);
        }

        if (eng6.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[6 - 1]);
          et.setOrderNum(new Integer(6));
          engTasks.add(et);
        }

        if (eng7.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[7 - 1]);
          et.setOrderNum(new Integer(7));
          engTasks.add(et);
        }

        if (eng8.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setNotes((String) (qvgate1.get("engOtherText")));
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[8 - 1]);
          et.setOrderNum(new Integer(8));
          engTasks.add(et);
        }

        // for each EngTask, add it to db and link it to this targetDoc
        for (Iterator iter = engTasks.iterator(); iter.hasNext(); ) {
          EngTask et = (EngTask) iter.next();

          // link this engTask to the targetDoc; add new engTask to db
          Integer z = ProjectService.getInstance().linkTargetDocEngTask(td, et);
        }
      }
    } // end if all.equals("on")
    else { // add tasks to all targets (actually a single "all" target)
      // for each source, add the new target to db and each target's new engineering tasks selected
      // from form
      for (int i = 0; i < sources.length; i++) {
        Set engTasks = new HashSet(); // list of new engTasks

        // target language's new object
        TargetDoc td = new TargetDoc(new HashSet(), new HashSet(), new HashSet(), new HashSet());
        td.setLanguage("All");
        SourceDoc sd = sources[i];

        // link this target Doc to the source Doc; add new target Doc to db
        Integer x = ProjectService.getInstance().linkSourceDocTargetDoc(sd, td);

        if (eng1.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[1 - 1]);
          et.setOrderNum(new Integer(1));
          engTasks.add(et);
        }

        if (eng2.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[2 - 1]);
          et.setOrderNum(new Integer(2));
          engTasks.add(et);
        }

        if (eng3.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[3 - 1]);
          et.setOrderNum(new Integer(3));
          engTasks.add(et);
        }

        if (eng4.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[4 - 1]);
          et.setOrderNum(new Integer(4));
          engTasks.add(et);
        }

        if (eng5.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[5 - 1]);
          et.setOrderNum(new Integer(5));
          engTasks.add(et);
        }

        if (eng6.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[6 - 1]);
          et.setOrderNum(new Integer(6));
          engTasks.add(et);
        }

        if (eng7.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[7 - 1]);
          et.setOrderNum(new Integer(7));
          engTasks.add(et);
        }

        if (eng8.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setNotes((String) (qvgate1.get("engOtherText")));
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[8 - 1]);
          et.setOrderNum(new Integer(8));
          engTasks.add(et);
        }

        // for each EngTask, add it to db and link it to this targetDoc
        for (Iterator iter = engTasks.iterator(); iter.hasNext(); ) {
          EngTask et = (EngTask) iter.next();

          // link this engTask to the targetDoc; add new engTask to db
          Integer z = ProjectService.getInstance().linkTargetDocEngTask(td, et);
        }
      }
    } // end else (new target per source with tasks)

    // Forward control to the specified success URI
    return (mapping.findForward("Success"));
  }
Exemplo n.º 9
0
 /**
  * Register an extra set of localized messages.
  *
  * @param name the base name of the resource bundle
  * @since 0.3
  */
 public void addResources(String name) {
   bundleNames.add(name);
 }