/**
   * Uses HttpUnit functionality to retrieve a single sds workgroup from the sds, including the
   * offering and the members
   *
   * @param sdsWorkgroupId The id of the workgroup you want to retrieve
   * @return The SdsWorkgroup with all parameters set.
   * @throws IOException
   * @throws JDOMException
   * @throws SAXException
   */
  @SuppressWarnings("unchecked")
  protected SdsWorkgroup getWorkgroupInSds(Serializable sdsWorkgroupId)
      throws IOException, JDOMException, SAXException {
    String WORKGROUP_PATH = "/workgroup/" + sdsWorkgroupId;
    WebResponse webResponse = this.makeHttpRestGetRequest(WORKGROUP_PATH);
    assertEquals(HttpStatus.SC_OK, webResponse.getResponseCode());

    Document doc = createDocumentFromResponse(webResponse);
    SdsWorkgroup sdsWorkgroup = (SdsWorkgroup) this.applicationContext.getBean("sdsWorkgroup");

    Element workgroupElement = doc.getRootElement();
    sdsWorkgroup.setName(workgroupElement.getChild("name").getValue());
    sdsWorkgroup.setSdsObjectId(new Long(workgroupElement.getChild("id").getValue()));

    Integer sdsOfferingId = new Integer(workgroupElement.getChild("offering-id").getValue());
    SdsOffering sdsOffering = this.getOfferingAlternativeMethod(sdsOfferingId);
    sdsWorkgroup.setSdsOffering(sdsOffering);

    WebResponse membersWebResponse = this.makeHttpRestGetRequest(WORKGROUP_PATH + "/membership");
    assertEquals(HttpStatus.SC_OK, membersWebResponse.getResponseCode());
    Document membersDoc = createDocumentFromResponse(membersWebResponse);

    List<Element> memberElements =
        XPath.newInstance("/workgroup-memberships/workgroup-membership/sail-user-id")
            .selectNodes(membersDoc);

    for (Element memberNode : memberElements) {
      SdsUser sdsUser = this.getUserInSds(new Long(memberNode.getValue()));
      sdsWorkgroup.addMember(sdsUser);
    }

    return sdsWorkgroup;
  }
  private JPanel readSplitter(
      JPanel panel, Element splitterElement, Ref<EditorWindow> currentWindow) {
    final boolean orientation =
        "vertical".equals(splitterElement.getAttributeValue("split-orientation"));
    final float proportion =
        Float.valueOf(splitterElement.getAttributeValue("split-proportion")).floatValue();
    final Element first = splitterElement.getChild("split-first");
    final Element second = splitterElement.getChild("split-second");

    Splitter splitter;
    if (panel == null) {
      panel = new JPanel(new BorderLayout());
      panel.setOpaque(false);
      splitter = new Splitter(orientation, proportion, 0.1f, 0.9f);
      panel.add(splitter, BorderLayout.CENTER);
      splitter.setFirstComponent(readExternalPanel(first, null, currentWindow));
      splitter.setSecondComponent(readExternalPanel(second, null, currentWindow));
    } else if (panel.getComponent(0) instanceof Splitter) {
      splitter = (Splitter) panel.getComponent(0);
      readExternalPanel(first, (JPanel) splitter.getFirstComponent(), currentWindow);
      readExternalPanel(second, (JPanel) splitter.getSecondComponent(), currentWindow);
    } else {
      readExternalPanel(first, panel, currentWindow);
      readExternalPanel(second, panel, currentWindow);
    }
    return panel;
  }
Example #3
0
 public void readExternal(Element element) throws InvalidDataException {
   Element passwords = element.getChild(PASSWORDS);
   if (passwords != null) {
     for (Iterator eachPasswordElement = passwords.getChildren(PASSWORD).iterator();
         eachPasswordElement.hasNext(); ) {
       Element passElement = (Element) eachPasswordElement.next();
       String cvsRoot = passElement.getAttributeValue(CVSROOT_ATTR);
       String password = passElement.getAttributeValue(PASSWORD_ATTR);
       if ((cvsRoot != null) && (password != null))
         myCvsRootToStoringPasswordMap.put(
             cvsRoot, PServerPasswordScrambler.getInstance().unscramble(password));
     }
   }
   passwords = element.getChild(PPKPASSWORDS);
   if (passwords != null) {
     for (Iterator eachPasswordElement = passwords.getChildren(PASSWORD).iterator();
         eachPasswordElement.hasNext(); ) {
       Element passElement = (Element) eachPasswordElement.next();
       String cvsRoot = passElement.getAttributeValue(CVSROOT_ATTR);
       String password = passElement.getAttributeValue(PASSWORD_ATTR);
       if ((cvsRoot != null) && (password != null))
         myCvsRootToStoringPPKPasswordMap.put(
             cvsRoot, PServerPasswordScrambler.getInstance().unscramble(password));
     }
   }
 }
Example #4
0
  /**
   * Devuelve la lista de páginas pertenecientes a la categoría dada
   *
   * @param categoria
   * @return
   * @throws IOException
   * @throws JDOMException
   */
  public List<String> getPaginas(String categoria) throws IOException, JDOMException {
    List<String> paginas = new LinkedList<String>();

    // Primero le quitamos al nombre los espacios en blanco
    String nombre = categoria.replaceAll(" ", "_");

    // Formamos la petición a wikipedia
    HashMap<String, String> campos = new HashMap<String, String>();
    campos.put("action", "query");
    campos.put("list", "categorymembers");
    campos.put("cmtitle", "Category:" + nombre);
    campos.put("cmlimit", "500");

    // Realizamos la conexión obteniendo el documento xml
    Document doc = getContenido(campos);

    Element elem = doc.getRootElement();
    Element aux = elem.getChild("query");
    aux = aux.getChild("categorymembers");

    Iterator<?> it = aux.getChildren().iterator();
    while (it.hasNext()) {
      Element cat = (Element) it.next();
      String texto = cat.getAttributeValue("title");
      if (texto.indexOf("Categoría") < 0) paginas.add(texto);
    }

    return paginas;
  }
 /**
  * Process kick from server
  *
  * @param doc
  */
 private void _kick(Document doc) {
   Element root = doc.getRootElement();
   Element kick = root.getChild("kick");
   String user = kick.getChild("user").getText();
   String answer = kick.getChild("answer").getText();
   if (answer.equals("OK") == true) sendMessage(SERVER, user + " was kicked from " + _group);
 }
Example #6
0
  /**
   * Returns a list of all the staging profile Ids.
   *
   * @return
   * @throws RESTLightClientException
   */
  @SuppressWarnings("unchecked")
  public List<StageProfile> getStageProfiles() throws RESTLightClientException {
    Document doc = get(PROFILES_PATH);

    // heavy lifting is done with xpath
    XPath profileXp = newXPath(STAGE_REPO_XPATH);

    List<Element> profiles;
    try {
      profiles = profileXp.selectNodes(doc.getRootElement());
    } catch (JDOMException e) {
      throw new RESTLightClientException(
          "XPath selection failed: '"
              + STAGE_REPO_XPATH
              + "' (Root node: "
              + doc.getRootElement().getName()
              + ").",
          e);
    }

    List<StageProfile> result = new ArrayList<StageProfile>();
    if (profiles != null) {
      for (Element profile : profiles) {
        // just pull out the id and name.
        String profileId = profile.getChild(PROFILE_ID_ELEMENT).getText();
        String name = profile.getChild(PROFILE_NAME_ELEMENT).getText();
        String mode = profile.getChild(PROFILE_MODE_ELEMENT).getText();

        result.add(new StageProfile(profileId, name, mode));
      }
    }
    return result;
  }
Example #7
0
  private SBOLRootObject createDnaComponent(String xml, SBOLDocument document) {
    SAXBuilder builder = new SAXBuilder();
    DnaComponent dnaComponent = SBOLFactory.createDnaComponent();
    try {
      Document doc = builder.build(new File(xml));
      Element rootEl = doc.getRootElement();

      Element list = rootEl.getChild("part_list").getChild("part");
      partId = Integer.parseInt(list.getChildText("part_id"));
      dnaComponent.setURI(URI.create(list.getChildText("part_url")));
      dnaComponent.setDisplayId(list.getChildText("part_name"));
      dnaComponent.setName(list.getChildText("part_short_name"));
      dnaComponent.setDescription(list.getChildText("part_short_desc"));
      Element seq = rootEl.getChild("part_list").getChild("part").getChild("sequences");

      dnaComponent.setDnaSequence(this.createDnaSequence(seq.getChildText("seq_data")));
      List<SequenceAnnotation> seqs = createAllDnaSubComponent(xml);
      System.out.println(seqs.size());
      for (int i = 0; i < seqs.size(); i++) dnaComponent.addAnnotation(seqs.get(i));

    } catch (JDOMException e) {
      //            e.printStackTrace();

    } catch (IOException e) {
      //            e.printStackTrace();
    }
    return dnaComponent;
  }
  private String validateConfig(ContentHandlerName contentHandlerName, String xmlData) {
    org.jdom.Element configEl;

    try {
      org.jdom.Element contentTypeEl = JDOMUtil.parseDocument(xmlData).getRootElement();
      org.jdom.Element moduleDataEl = contentTypeEl.getChild("moduledata");
      if (moduleDataEl == null) {
        configEl = contentTypeEl.getChild("config");
      } else {
        configEl = moduleDataEl.getChild("config");
      }

    } catch (IOException e) {
      throw new RuntimeException("Failed to validate content type config", e);
    } catch (JDOMException e) {
      throw new RuntimeException("Failed to validate content type config", e);
    }

    if (configEl != null) {
      // Parse the content type config... the parser will throw exceptions if anything is not
      // correctly written
      try {
        if (contentHandlerName.equals(ContentHandlerName.CUSTOM)) {
          final ContentTypeConfig contentTypeConfig =
              ContentTypeConfigParser.parse(contentHandlerName, configEl);
          contentTypeConfig.validate();
        }
      } catch (InvalidContentTypeConfigException e) {
        return e.getMessage();
      }
    }

    return null;
  }
 @Override
 protected void extractValidationRules(Element validationElement) {
   super.extractValidationRules(validationElement);
   String maxLength = this.extractValue(validationElement, "maxlength");
   if (null != maxLength) {
     this.setMaxLength(Integer.parseInt(maxLength));
   }
   String minLength = this.extractValue(validationElement, "minlength");
   if (null != minLength) {
     this.setMinLength(Integer.parseInt(minLength));
   }
   String regexp = this.extractValue(validationElement, "regexp");
   if (null != regexp && regexp.trim().length() > 0) {
     this.setRegexp(regexp);
   }
   Element valueElement = validationElement.getChild("value");
   if (null != valueElement) {
     this.setValue(valueElement.getText());
     this.setValueAttribute(valueElement.getAttributeValue("attribute"));
   }
   Element rangeStartElement = validationElement.getChild("rangestart");
   if (null != rangeStartElement) {
     this.setRangeStart(rangeStartElement.getText());
     this.setRangeStartAttribute(rangeStartElement.getAttributeValue("attribute"));
   }
   Element rangeEndElement = validationElement.getChild("rangeend");
   if (null != rangeEndElement) {
     this.setRangeEnd(rangeEndElement.getText());
     this.setRangeEndAttribute(rangeEndElement.getAttributeValue("attribute"));
   }
 }
Example #10
0
 public static DefaultCellInfo loadFrom(Element e) {
   String cellId;
   int cellNumber;
   boolean isInList;
   final String nodeReference;
   DefaultCellInfo parentInfo = null;
   cellId = e.getAttributeValue(CELL_ID);
   String num = e.getAttributeValue(CELL_NUMBER);
   if (num == null) return null;
   try {
     cellNumber = Integer.parseInt(num);
   } catch (NumberFormatException ex) {
     return null;
   }
   isInList = "true".equals(e.getAttributeValue(IS_IN_LIST));
   Element nodeElem = e.getChild(NODE);
   if (nodeElem == null) return null;
   nodeReference = nodeElem.getAttributeValue(NODE_REFERENCE);
   if (nodeReference == null) return null;
   Element parentElem = e.getChild(PARENT);
   if (parentElem != null) {
     parentInfo = loadFrom(parentElem);
     if (parentInfo == null) return null;
   }
   final DefaultCellInfo result = new DefaultCellInfo();
   result.myNodeReference = PersistenceFacade.getInstance().createNodeReference(nodeReference);
   result.myCellId = cellId;
   result.myParentInfo = parentInfo;
   result.myIsInList = isInList;
   result.myCellNumber = cellNumber;
   return result;
 }
Example #11
0
 private String getTagData(Element root, String name) {
   // Isolate the EPC code using a very painful recursive method.
   Element tagReportData = root.getChild("TagReportData", root.getNamespace());
   Element dataElement = tagReportData.getChild(name, root.getNamespace());
   String data = dataElement.getContent(0).getValue();
   return data.toString();
 }
Example #12
0
  /*
   * (non-Javadoc)
   *
   * @see com.sun.syndication.io.ModuleParser#parse(org.jdom.Element)
   */
  public Module parse(Element element) {
    GeoRSSModule geoRSSModule = null;
    new SimpleModuleImpl();

    Element pointElement = element.getChild("point", GeoRSSModule.SIMPLE_NS);
    Element lineElement = element.getChild("line", GeoRSSModule.SIMPLE_NS);
    Element polygonElement = element.getChild("polygon", GeoRSSModule.SIMPLE_NS);
    Element boxElement = element.getChild("box", GeoRSSModule.SIMPLE_NS);
    if (pointElement != null) {
      geoRSSModule = new SimpleModuleImpl();
      String coordinates = pointElement.getText();
      String[] coord = coordinates.trim().split(" ");
      Position pos = new Position(Double.parseDouble(coord[1]), Double.parseDouble(coord[0]));
      geoRSSModule.setGeometry(new Point(pos));
    } else if (lineElement != null) {
      geoRSSModule = new SimpleModuleImpl();
      PositionList posList = parsePosList(lineElement);
      geoRSSModule.setGeometry(new LineString(posList));
    } else if (polygonElement != null) {
      geoRSSModule = new SimpleModuleImpl();
      PositionList posList = parsePosList(polygonElement);
      Polygon poly = new Polygon();
      poly.setExterior(new LinearRing(posList));
      geoRSSModule.setGeometry(poly);
    } else {
      geoRSSModule = (GeoRSSModule) GMLParser.parseGML(element);
    }

    return geoRSSModule;
  }
 @Override
 public void readExternal(Element element) throws InvalidDataException {
   if (element == null) {
     throw new InvalidDataException("Cant read " + this + ": element is null.");
   }
   XmlSerializer.deserializeInto(myState, (Element) element.getChildren().get(0));
   {
     Element fieldElement = element.getChild("myNode");
     if (fieldElement != null) {
       myNode.readExternal(fieldElement);
     } else {
       if (log.isDebugEnabled()) {
         log.debug("Element " + "myNode" + " in " + this.getClass().getName() + " was null.");
       }
     }
   }
   {
     Element fieldElement = element.getChild("mySettings");
     if (fieldElement != null) {
       mySettings.readExternal(fieldElement);
     } else {
       if (log.isDebugEnabled()) {
         log.debug("Element " + "mySettings" + " in " + this.getClass().getName() + " was null.");
       }
     }
   }
 }
Example #14
0
  private void createMethod(Element method) throws IllegalXMLVMException {
    il = new InstructionList();
    instructionHandlerManager = new InstructionHandlerManager(il);
    String methodName = method.getAttributeValue("name");

    Element signature = method.getChild("signature", nsXMLVM);
    Type retType = collectReturnType(signature);
    Type[] argTypes = collectArgumentTypes(signature);
    short accessFlags = getAccessFlags(method);

    if (methodName.equals(
        ".cctor")) // Same concept, different names in .net/JVM.  Note we are doing init of statics
                   // for a class
    {
      System.out.println("Changed name to clinit");
      methodName = "<clinit>";
      accessFlags = 0x8; // static
    }

    MethodGen m =
        new MethodGen(
            accessFlags, retType, argTypes, null, methodName, fullQualifiedClassName, il, _cp);
    Element code = method.getChild("code", nsXMLVM);
    createCode(code);
    instructionHandlerManager.checkConsistency();
    m.setMaxLocals();
    m.setMaxStack();
    _cg.addMethod(m.getMethod());
    il.dispose();
  }
Example #15
0
  /**
   * Method used to create one quest by receiving its information from the XML
   *
   * @param child an object of the class Element
   */
  public void createQuest(Element child) {

    // put the new quest in the hash, need to test if already has a quest
    // with this identifier, if already exists then don´t create the last

    // create the quest
    Quest quest = quests.get(child.getName());

    // test if exists, if doesn´t exists then create it
    if (quest == null) {
      // pass the element of the quest for it to be created

      // get the data for the quest
      quest = new Quest();

      // get the information
      createInformation(child.getChild("Information"), quest);

      // get the dependencies
      createDependencies(child.getChild("Dependencies"), quest);

      // get the objective
      createObjective(child.getChild("Objective"), quest);

      // get the rewards
      createReward(child.getChild("Reward"), quest);

      // put the quest in the hash
      quests.put(quest.getName(), quest);
    }
  }
Example #16
0
 public void createMessageFiles(String modelFileName) {
   try {
     System.out.println(modelFileName);
     msgs = new HashMap<String, MessageObject>();
     fields = new HashMap<String, List<FieldObject>>();
     String configFilePath = GeneratorHelper.getBuildPath(MODEL_DIC + modelFileName);
     SAXBuilder builder = new SAXBuilder();
     Document doc = builder.build(configFilePath);
     Element root = doc.getRootElement();
     String module = root.getAttributeValue("module"); // 所属模块
     List messages = root.getChildren("message", NAME_SPACE); // 消息体定义
     List constants = null;
     Element constantsElement = root.getChild("constants", NAME_SPACE);
     if (constantsElement != null) {
       constants = root.getChild("constants", NAME_SPACE).getChildren(); // 常量定义
     } else {
       constants = new ArrayList();
     }
     this.replaceMacros(messages);
     createServerFiles(messages, module);
     createClientFile(messages, module, constants);
     createServerMappingFile(messages, module);
     createRobotServerMappingFile(messages, module);
   } catch (Exception e) {
     logger.error("", e);
   }
 }
Example #17
0
  @SuppressWarnings("unchecked")
  private Role parseRole(Element element) throws RESTLightClientException {
    Role role = new Role();

    role.setResourceURI(element.getChildText(RESOURCE_URI_ELEMENT));
    role.setId(element.getChildText(ROLE_ID_ELEMENT));
    role.setName(element.getChildText(ROLE_NAME_ELEMENT));
    role.setDescription(element.getChildText(ROLE_DESCRIPTION_ELEMENT));
    role.setSessionTimeout(Integer.parseInt(element.getChildText(ROLE_SESSION_TIMEOUT_ELEMENT)));

    Element subRoles = element.getChild(ROLE_ROLES_ELEMENT);

    if (subRoles != null) {
      for (Element subRole : (List<Element>) subRoles.getChildren(ROLE_ROLE_ELEMENT)) {
        role.getRoles().add(subRole.getValue());
      }
    }

    Element privileges = element.getChild(ROLE_PRIVILEGES_ELEMENT);

    if (privileges != null) {
      for (Element privilege : (List<Element>) privileges.getChildren(ROLE_PRIVILEGE_ELEMENT)) {
        role.getPrivileges().add(privilege.getValue());
      }
    }

    role.setUserManaged(
        element.getChildText(ROLE_USER_MANAGED_ELEMENT).equals("true") ? true : false);

    return role;
  }
  /** {@inheritDoc} */
  public void decodeXML(Element element) throws InvalidLLRPMessageException {
    List<Element> tempList = null;
    boolean atLeastOnce = false;
    Custom custom;

    Element temp = null;

    // child element are always in default LLRP namespace
    Namespace ns = Namespace.getNamespace(LLRPConstants.LLRPNAMESPACE);

    temp = element.getChild("I", ns);

    if (temp != null) {
      i = new C1G2TagInventoryStateAwareI(temp);
    }

    element.removeChild("I", ns);
    temp = element.getChild("S", ns);

    if (temp != null) {
      s = new C1G2TagInventoryStateAwareS(temp);
    }

    element.removeChild("S", ns);

    if (element.getChildren().size() > 0) {
      String message =
          "C1G2TagInventoryStateAwareSingulationAction has unknown element "
              + ((Element) element.getChildren().get(0)).getName();
      throw new InvalidLLRPMessageException(message);
    }
  }
Example #19
0
  @SuppressWarnings("unchecked")
  private ProjectModuleBO convertElementToModule(Element element) {
    ProjectModuleBO module = new ProjectModuleBO();
    module.setId(Long.parseLong(element.getAttributeValue(ATTR_ID)));
    module.setModuleName(element.getAttributeValue(ATTR_NAME));
    module.setRemark(element.getAttributeValue(ATTR_REMARK));

    Element developerElement = element.getChild(NODE_DEV);
    module.setDevelopers(developerElement.getAttributeValue(ATTR_ID));
    Element packageElement = element.getChild(NODE_PACKAGE);

    List<Element> packageChildren = packageElement.getChildren();
    for (Element packElement : packageChildren) {
      String packName = packElement.getAttributeValue(ATTR_NAME);
      if (StringUtils.isEqual(packElement.getName(), NODE_SRC)) module.setSrcPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_JSP)) module.setJspPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_HBM)) module.setHbmPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_SPRING))
        module.setSpringPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_PAGEFLOW))
        module.setPageflowPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_VAR)) module.setVarPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_I18N))
        module.setI18nPackage(packName);
    }
    return module;
  }
  public void fromJDOM(Element element) {
    /* Mistake?
    // Ensure we have matching pairs
    List<?> property_refs = element.getChildren(LDModelFactory.PROPERTY_REF, IMSLD_NAMESPACE_100_EMBEDDED);
    List<?> property_values = element.getChildren(LDModelFactory.PROPERTY_VALUE, IMSLD_NAMESPACE_100_EMBEDDED);

    if(property_refs != null && property_values != null && property_refs.size() == property_values.size()) {
        for(int i = 0; i < property_refs.size(); i++) {
            IPropertyRefValuePair refvalue = new PropertyRefValuePair(fLDModel);
            refvalue.getPropertyRef().fromJDOM((Element)property_refs.get(i));
            refvalue.getPropertyValue().fromJDOM((Element)property_values.get(i));
            fPropertyRefValuePairs.add(refvalue);
        }
    }
    */

    Element property_ref =
        element.getChild(LDModelFactory.PROPERTY_REF, IMSLD_NAMESPACE_100_EMBEDDED);
    if (property_ref != null) {
      fPropertyRefValuePair.getPropertyRef().fromJDOM(property_ref);
    }

    Element property_value =
        element.getChild(LDModelFactory.PROPERTY_VALUE, IMSLD_NAMESPACE_100_EMBEDDED);
    if (property_value != null) {
      fPropertyRefValuePair.getPropertyValue().fromJDOM(property_value);
    }
  }
  public void create(Element node) throws BadInputEx {
    Element site = node.getChild("site");
    Element opt = node.getChild("options");
    Element content = node.getChild("content");

    Element account = (site == null) ? null : site.getChild("account");

    name = Util.getParam(site, "name", "");
    uuid = Util.getParam(site, "uuid", UUID.randomUUID().toString());

    useAccount = Util.getParam(account, "use", false);
    username = Util.getParam(account, "username", "");
    password = Util.getParam(account, "password", "");

    every = Util.getParam(opt, "every", "0 0 0 * * ?");

    oneRunOnly = Util.getParam(opt, "oneRunOnly", false);

    getTrigger();

    importXslt = Util.getParam(content, "importxslt", "none");
    validate = Util.getParam(content, "validate", false);

    addPrivileges(node.getChild("privileges"));
    addCategories(node.getChild("categories"));

    this.node = node;
  }
  private static void readCalibrationLUT(
      final File file, final String lutName, final MetadataElement root, final boolean flipLUT)
      throws IOException {
    if (!file.exists()) return;
    final org.jdom.Document xmlDoc = XMLSupport.LoadXML(file.getAbsolutePath());
    final Element rootElement = xmlDoc.getRootElement();

    final Element offsetElem = rootElement.getChild("offset");
    final double offset = Double.parseDouble(offsetElem.getValue());

    final Element gainsElem = rootElement.getChild("gains");
    double[] gainsArray = StringUtils.toDoubleArray(gainsElem.getValue().trim(), " ");
    if (flipLUT) {
      double tmp;
      for (int i = 0; i < gainsArray.length / 2; i++) {
        tmp = gainsArray[i];
        gainsArray[i] = gainsArray[gainsArray.length - i - 1];
        gainsArray[gainsArray.length - i - 1] = tmp;
      }
    }

    final MetadataElement lut = new MetadataElement(lutName);
    root.addElement(lut);

    final MetadataAttribute offsetAttrib =
        new MetadataAttribute("offset", ProductData.TYPE_FLOAT64);
    offsetAttrib.getData().setElemDouble(offset);
    lut.addAttribute(offsetAttrib);

    final MetadataAttribute gainsAttrib =
        new MetadataAttribute("gains", ProductData.TYPE_FLOAT64, gainsArray.length);
    gainsAttrib.getData().setElems(gainsArray);
    lut.addAttribute(gainsAttrib);
  }
Example #23
0
 /**
  * Process Message from server
  *
  * @param doc
  */
 private void _message(Document doc) {
   Element root = doc.getRootElement();
   Element message = root.getChild("message");
   String sender = message.getChild("sender").getText();
   String mesg = message.getChild("mesg").getText();
   sendMessage(NORMAL, sender + ": " + mesg);
 }
 private void applySampler(final Element sampler, final Texture texture) {
   if (sampler.getChild("minfilter") != null) {
     final String minfilter = sampler.getChild("minfilter").getText();
     texture.setMinificationFilter(
         Enum.valueOf(SamplerTypes.MinFilterType.class, minfilter).getArdor3dFilter());
   }
   if (sampler.getChild("magfilter") != null) {
     final String magfilter = sampler.getChild("magfilter").getText();
     texture.setMagnificationFilter(
         Enum.valueOf(SamplerTypes.MagFilterType.class, magfilter).getArdor3dFilter());
   }
   if (sampler.getChild("wrap_s") != null) {
     final String wrapS = sampler.getChild("wrap_s").getText();
     texture.setWrap(
         Texture.WrapAxis.S,
         Enum.valueOf(SamplerTypes.WrapModeType.class, wrapS).getArdor3dWrapMode());
   }
   if (sampler.getChild("wrap_t") != null) {
     final String wrapT = sampler.getChild("wrap_t").getText();
     texture.setWrap(
         Texture.WrapAxis.T,
         Enum.valueOf(SamplerTypes.WrapModeType.class, wrapT).getArdor3dWrapMode());
   }
   if (sampler.getChild("border_color") != null) {
     texture.setBorderColor(_colladaDOMUtil.getColor(sampler.getChild("border_color").getText()));
   }
 }
 public void readExternal(final Element element) throws InvalidDataException {
   PathMacroManager.getInstance(getProject()).expandPaths(element);
   super.readExternal(element);
   JavaRunConfigurationExtensionManager.getInstance().readExternal(this, element);
   readModule(element);
   DefaultJDOMExternalizer.readExternal(this, element);
   DefaultJDOMExternalizer.readExternal(getPersistentData(), element);
   EnvironmentVariablesComponent.readExternal(element, getPersistentData().getEnvs());
   final Element patternsElement = element.getChild(PATTERNS_EL_NAME);
   if (patternsElement != null) {
     final Set<String> tests = new LinkedHashSet<String>();
     for (Object o : patternsElement.getChildren(PATTERN_EL_NAME)) {
       Element patternElement = (Element) o;
       tests.add(patternElement.getAttributeValue(TEST_CLASS_ATT_NAME));
     }
     myData.setPatterns(tests);
   }
   final Element forkModeElement = element.getChild("fork_mode");
   if (forkModeElement != null) {
     final String mode = forkModeElement.getAttributeValue("value");
     if (mode != null) {
       setForkMode(mode);
     }
   }
   final Element dirNameElement = element.getChild("dir");
   if (dirNameElement != null) {
     final String dirName = dirNameElement.getAttributeValue("value");
     getPersistentData().setDirName(FileUtil.toSystemDependentName(dirName));
   }
 }
Example #26
0
  public void createDependencies(Element dep, Quest quest) {
    if (dep != null) {

      // if there are quests
      if (dep.getChild("Quest") != null) {
        // get the quest dependencies
        quest.setQuestDependencies(loadOneDependencie(dep.getChild("Quest")));
      }

      // if there are itens needed
      if (dep.getChild("Itens") != null) {
        // get the Itens
        Object[] objects;
        objects = loadTwoDependencies(dep.getChild("Itens"));
        // set their places
        quest.setItemDependencies((String[]) objects[0]);
        quest.setItemDependenciesQuantity((int[]) objects[1]);
      }

      // if exists the need for levels
      if (dep.getChild("Level") != null) {
        // get the Level
        quest.setLevelDependencie(Integer.parseInt(dep.getChildText("Level")));
      }
    }
  }
Example #27
0
  public DataSource createDataSource() {

    SAXBuilder sb = new SAXBuilder();
    DataSource dataSource = null;
    try {
      Document xmlDoc = sb.build("config/data.xml");
      Element root = xmlDoc.getRootElement();
      Element url = root.getChild("url");

      dataSource = new DataSource();
      dataSource.setHost(url.getText());
      dataSource.setDbName(root.getChild("database").getText());
      dataSource.setDriverClass(root.getChildText("driver-class"));
      dataSource.setPort(root.getChildText("port"));
      dataSource.setUserLogin(root.getChildText("login"));
      dataSource.setUserPwd(root.getChildText("password"));

    } catch (JDOMException e) {
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return dataSource;
  }
Example #28
0
  public void createReward(Element rew, Quest quest) {
    if (rew != null) {

      // if there´s money to be rewarded
      if (rew.getChild("Money") != null) {
        quest.setMoneyRewarded(Integer.parseInt(rew.getChildText("Money")));
      } else {
        // if there´s no money reward
        quest.setMoneyRewarded(-1);
      }

      // if there´s one or more itens to be rewarded
      if (rew.getChild("Itens") != null) {
        // get the Itens
        Object[] objects;
        objects = loadTwoDependencies(rew.getChild("Itens"));
        // set their places
        quest.setRewardItem((String[]) objects[0]);
        quest.setRewardedItem((int[]) objects[1]);
      }

      // if there´s something of the character that increases
      if (rew.getChild("Features") != null) {
        // get the Itens
        Object[] objects;
        objects = loadThreeDependencies(rew.getChild("Features"));
        // set their places
        quest.setFeatureName((String[]) objects[0]);
        quest.setFeatureType((String[]) objects[1]);
        quest.setFeatureValue((int[]) objects[2]);
      }
    }
  }
    @Nullable
    public T process(@Nullable Element element, @Nullable T context) {
      if (element == null) {
        return null;
      }
      final Element splitterElement = element.getChild("splitter");
      if (splitterElement != null) {
        final Element first = splitterElement.getChild("split-first");
        final Element second = splitterElement.getChild("split-second");
        return processSplitter(splitterElement, first, second, context);
      }

      final Element leaf = element.getChild("leaf");
      if (leaf == null) {
        return null;
      }

      List<Element> fileElements = leaf.getChildren("file");
      final List<Element> children = new ArrayList<Element>(fileElements.size());

      // trim to EDITOR_TAB_LIMIT, ignoring CLOSE_NON_MODIFIED_FILES_FIRST policy
      int toRemove = fileElements.size() - UISettings.getInstance().EDITOR_TAB_LIMIT;
      for (Element fileElement : fileElements) {
        if (toRemove <= 0
            || Boolean.valueOf(fileElement.getAttributeValue(PINNED)).booleanValue()) {
          children.add(fileElement);
        } else {
          toRemove--;
        }
      }

      return processFiles(children, context);
    }
  /**
   * Uses HttpUnit functionality to retrieve a single sds offering (including curnit and jnlp) from
   * the sds.
   *
   * @param sdsOfferingId The id of the offering you want to retrieve
   * @return The SdsOffering with all parameters set.
   * @throws IOException
   * @throws JDOMException
   * @throws SAXException
   */
  protected SdsOffering getOfferingAlternativeMethod(Serializable sdsOfferingId)
      throws IOException, JDOMException, SAXException {
    WebResponse webResponse = this.makeHttpRestGetRequest("/offering/" + sdsOfferingId);
    assertEquals(HttpStatus.SC_OK, webResponse.getResponseCode());

    Document doc = createDocumentFromResponse(webResponse);
    SdsOffering sdsOffering = (SdsOffering) this.applicationContext.getBean("sdsOffering");
    Element offeringElement = doc.getRootElement();
    sdsOffering.setName(offeringElement.getChild("name").getValue());
    sdsOffering.setSdsObjectId(new Long(offeringElement.getChild("id").getValue()));

    Long sdsCurnitId = new Long(offeringElement.getChild("curnit-id").getValue());
    SdsCurnit sdsCurnit = this.getCurnitInSds(sdsCurnitId);
    sdsOffering.setSdsCurnit(sdsCurnit);

    Long sdsJnlpId = new Long(offeringElement.getChild("jnlp-id").getValue());
    SdsJnlp sdsJnlp = this.getJnlpInSds(sdsJnlpId);
    sdsOffering.setSdsJnlp(sdsJnlp);

    WebResponse curnitMapWebResponse =
        this.makeHttpRestGetRequest("/offering/" + sdsOfferingId + "/curnitmap");
    assertEquals(HttpStatus.SC_OK, curnitMapWebResponse.getResponseCode());

    Document curnitMapDoc = createDocumentFromResponse(curnitMapWebResponse);
    sdsOffering.setSdsCurnitMap(curnitMapDoc.getRootElement().getText());

    return sdsOffering;
  }