@Override
 public boolean has(String name, Scriptable start) {
   if (wrapped == null) {
     return super.has(name, this);
   }
   return wrapped.has(name, wrapped) || properties.has(name, properties);
 }
 @Override
 public void delete(String name) {
   if (wrapped == null) {
     super.delete(name);
   } else {
     if (properties.has(name, properties)) {
       properties.delete(name);
     } else {
       wrapped.delete(name);
     }
   }
 }
 @Override
 public void put(String name, Scriptable start, Object value) {
   if (wrapped == null) {
     super.put(name, this, value);
   } else {
     if (properties.has(name, start)) {
       properties.put(name, properties, value);
     } else {
       wrapped.put(name, wrapped, value);
     }
   }
 }
Пример #4
0
  /**
   * List the open invitations for this web site. props specifies optional properties to be
   * searched.
   *
   * @param props inviteeUserName
   * @return the invitations
   */
  public ScriptInvitation<?>[] listInvitations(Scriptable props) {
    InvitationSearchCriteriaImpl crit = new InvitationSearchCriteriaImpl();
    crit.setResourceName(getShortName());
    crit.setResourceType(Invitation.ResourceType.WEB_SITE);

    if (props.has("inviteeUserName", props)) {
      crit.setInvitee((String) props.get("inviteeUserName", props));
    }
    if (props.has("invitationType", props)) {
      String invitationType = (String) props.get("invitationType", props);
      crit.setInvitationType(InvitationType.valueOf(invitationType));
    }

    List<Invitation> invitations = invitationService.searchInvitation(crit);
    ScriptInvitation<?>[] ret = new ScriptInvitation[invitations.size()];
    int i = 0;
    for (Invitation item : invitations) {
      ret[i++] = scriptInvitationFactory.toScriptInvitation(item);
    }
    return ret;
  }
Пример #5
0
  /**
   * Executes a method script. Each script should be identified with a unique name within the scope
   * (such as "afterOpen", "onFetch" etc.). This class assumes that the content of a named method
   * script is immutable, therefore it defines each named script only once.
   *
   * @param methodName Identification of the script
   * @param script Script text
   * @param id script id using in debug mode
   * @return Return value from the script
   */
  public Object runScript(String methodName, String script, String id) throws BirtException {
    // Add a prefix to the method name so it has less chance of conflict with regular functions
    methodName = METHOD_NAME_PREFIX + methodName;

    try {
      // Check if method already defined in scope
      if (!scope.has(methodName, scope)) {

        // Define the method for the first time
        String scriptText = "function " + methodName + "() {\n" + script + "\n} ";
        ScriptEvalUtil.evaluateJSAsExpr(cx, scope, scriptText, id, 1);
      }

      // Call pre-defined method
      String callScriptText = methodName + "()";
      Object result = ScriptEvalUtil.evaluateJSAsExpr(cx, scope, callScriptText, id, 1);
      return result;
    } catch (DataException e) {
      throw new DataException(
          ResourceConstants.SCIRPT_FUNCTION_EXECUTION_FAIL, e, new Object[] {methodName, script});
    }
  }
Пример #6
0
 private boolean isArrayLike(Scriptable svalue) {
   return svalue.has("length", svalue);
 }