Exemple #1
0
 /**
  * project this StringTupel to a given set of keys
  *
  * @param keys the keys to retain
  * @return a new StringTupel containing only the values of the specified keys
  */
 public StringTupel project(StringVector keys) {
   StringVector remainingKeys = this.getKeys().intersect(keys);
   StringTupel st = new StringTupel();
   for (int k = 0; k < remainingKeys.size(); k++)
     st.setValue(remainingKeys.get(k), this.getValue(remainingKeys.get(k)));
   return st;
 }
Exemple #2
0
 /**
  * join this StringTupel with another one
  *
  * @param toJoin the StringTupel to join this one with
  * @return a new StringTupel containing the key/value pairs from both this and the argument
  *     StringTupel Note: if the values for a key differ, the new StringTupel will contain the
  *     value from this StringTupel
  */
 public StringTupel join(StringTupel toJoin) {
   if ((toJoin == null) || (toJoin == this)) return this;
   StringVector joinKeys = this.getKeys().union(toJoin.getKeys());
   StringTupel st = new StringTupel();
   for (int k = 0; k < joinKeys.size(); k++)
     st.setValue(
         joinKeys.get(k), this.getValue(joinKeys.get(k), toJoin.getValue(joinKeys.get(k))));
   return st;
 }
Exemple #3
0
 /**
  * Convert the data in this StringTupel to a line for a CSV file.
  *
  * @param separator the value separator character
  * @param valueDelimiter the character to use as the value delimiter (will be escaped with itself
  *     if occuring in value)
  * @param keys a StringVector containing the keys whose values to include
  * @return a String concatenated from the values of the specified keys, in the order of the keys
  */
 public String toCsvString(char separator, char valueDelimiter, StringVector keys) {
   String delimiter = ("" + valueDelimiter);
   StringVector values = new StringVector();
   for (int k = 0; k < keys.size(); k++)
     values.addElement(
         delimiter
             + StringUtils.replaceAll(
                 this.getValue(keys.get(k), ""), delimiter, (delimiter + delimiter))
             + delimiter);
   return values.concatStrings("" + separator);
 }
 /* (non-Javadoc)
  * @see de.uka.ipd.idaho.goldenGate.plugins.AbstractGoldenGatePlugin#init()
  */
 public void init() {
   try {
     StringVector sats =
         StringVector.loadList(this.dataProvider.getInputStream("structureAnnotationTypes.cnfg"));
     for (int t = 0; t < sats.size(); t++) {
       String sat = sats.get(t).trim();
       if ((sat.length() == 0) || sat.startsWith("//")) continue;
       this.structureAnnotationTypes.add(sat);
     }
   } catch (IOException ioe) {
   }
 }
Exemple #5
0
 /**
  * check if this StringTupel matches a given filter
  *
  * @param filter the StringTupel to use as the filter
  * @return true if and only if this StringTupel contains the same values as the filter for all
  *     keys contained in the filter
  */
 public boolean matches(StringTupel filter) {
   if ((filter == null) || (filter.size() == 0)) return true;
   StringVector ownKeys = this.getKeys();
   StringVector filterKeys = filter.getKeys();
   if (!ownKeys.contains(filterKeys)) return false;
   for (int k = 0; k < filterKeys.size(); k++) {
     String ownValue = this.getValue(filterKeys.get(k), "");
     String filterValue = filter.getValue(filterKeys.get(k), "");
     if (!ownValue.equals(filterValue)) return false;
   }
   return true;
 }
Exemple #6
0
 void getKeys(StringVector sv) {
   for (Iterator kit = this.data.keySet().iterator(); kit.hasNext(); )
     sv.addElementIgnoreDuplicates((String) kit.next());
 }
Exemple #7
0
 /** @see java.lang.Object#hashCode() */
 public int hashCode() {
   StringVector keys = this.getKeys();
   keys.sortLexicographically();
   String csv = this.toCsvString(keys);
   return csv.hashCode();
 }
Exemple #8
0
 /** @see java.lang.Object#toString() */
 public String toString() {
   StringVector keys = this.getKeys();
   StringVector values = new StringVector();
   for (int k = 0; k < keys.size(); k++) values.addElement(this.getValue(keys.get(k), ""));
   return values.concatStrings("; ");
 }
  /* (non-Javadoc)
   * @see de.uka.ipd.idaho.goldenGateScf.uaa.webClient.AuthenticatedWebClientModul#handleRequest(de.uka.ipd.idaho.goldenGateScf.uaa.client.AuthenticatedClient, javax.servlet.http.HttpServletRequest)
   */
  public String[] handleRequest(AuthenticatedClient authClient, HttpServletRequest request)
      throws IOException {
    GoldenGateUpsClient upsc = this.getUpsClient(authClient);
    StringVector messageCollector = new StringVector();

    String command = request.getParameter(COMMAND_PARAMETER);

    //	create role
    if (CREATE_ROLE.equals(command)) {

      //	get parameters
      String roleName = request.getParameter(ROLE_NAME_PARAMETER);

      //	create role
      upsc.createRole(roleName);
      messageCollector.addElement("Role '" + roleName + "' created successfully.");
    }

    //	delete role
    else if (DELETE_ROLE.equals(command)) {

      //	get parameters
      String roleName = request.getParameter(ROLE_NAME_PARAMETER);

      //	delete role
      upsc.deleteRole(roleName);
      messageCollector.addElement("Role '" + roleName + "' deleted successfully.");
    }

    //	edit a user's roles and permissions
    else if (EDIT_USER.equals(command)) {

      //	get parameters
      String userName = request.getParameter(USER_NAME_PARAMETER);
      String[] roles = request.getParameterValues(ROLE_PARAMETER);

      //	set roles
      upsc.setUserRoles(userName, roles);
      messageCollector.addElement("Roles of user '" + userName + "' changed successfully.");
    }

    //	edit a role's roles and permissions
    else if (EDIT_ROLE.equals(command)) {

      //	get parameters
      String roleName = request.getParameter(ROLE_NAME_PARAMETER);
      String[] roles = request.getParameterValues(ROLE_PARAMETER);
      String[] permissions = request.getParameterValues(PERMISSION_PARAMETER);

      //	set roles
      upsc.setRoleRoles(roleName, roles);
      messageCollector.addElement(
          "Inherited roles of role '" + roleName + "' changed successfully.");

      //	set permissions
      upsc.setRolePermissions(roleName, permissions);
      messageCollector.addElement("Permissions of role '" + roleName + "' changed successfully.");
    }

    return messageCollector.toStringArray();
  }