Package fr.norsys.mapper.console.model

Examples of fr.norsys.mapper.console.model.Variable


   * @param variable
   * @param variables
   * @return
   */
  private void add(Variable variable, Collection variables) {
    Variable v = null;
    try {
      v = (Variable) BeanUtils.cloneBean(variable);
    } catch (Exception e) {
    }
    v.setId(UIDGenerator.generateId());
    variables.add(v);
  }
View Full Code Here


   * @param variable
   * @param variables
   * @return
   */
  private void modify(Variable var, Collection variables) {
    Variable variable = var;
    for (Iterator it = variables.iterator(); it.hasNext();) {
      Variable c = (Variable) it.next();
      if (variable.getId().equals(c.getId())) {
        fr.norsys.mapper.console.utils.BeanUtils.copyFilledProperties(
            c, variable);
        variable = c;
        break;
      }
View Full Code Here

   * @param variables
   * @return
   */
  public void delete(String id, Collection variables) {
    for (Iterator it = variables.iterator(); it.hasNext();) {
      Variable v = (Variable) it.next();
      if (v.getId().equals(id)) {
        variables.remove(v);
        break;
      }
    }
  }
View Full Code Here

   * @param id
   * @param variables
   * @return Variable
   */
  public Variable get(String id, Collection variables) {
    Variable result = null;
    for (Iterator it = variables.iterator(); it.hasNext();) {
      Variable c = (Variable) it.next();
      if (c.getId().equals(id)) {
        result = c;
      }
    }
    return result;
  }
View Full Code Here

   * @return boolean
   */
  public boolean nameAlreadyInUse(String id, String name, Collection variables) {
    boolean result = false;
    for (Iterator it = variables.iterator(); it.hasNext();) {
      Variable v = (Variable) it.next();
      if (v.getName().equals(name) && !v.getId().equals(id)) {
        result = true;
      }
    }
    return result;
  }
View Full Code Here

    String id = request.getParameter("id");
    DynaActionForm variableForm = (DynaActionForm) form;
    if (id != null && !"".equals(id)) {
      Application currentAppl = (Application) request.getSession()
          .getAttribute(ConsoleCst.CURRENT_APPLICATION);
      Variable variable = variableService.get(id, currentAppl
          .getVariables());
      variableForm.set(ConsoleCst.VARIABLE_REQUEST_BEAN, variable);
    }
    request.getSession().setAttribute(ConsoleCst.IS_APPLICATION_MODIFIED,
        ConsoleCst.APPLICATION_MODIFIED);
View Full Code Here

    assertEquals("res3",((Resource)((TreeSet) resources).last()).getName());
    if(log.isDebugEnabled())
      log.debug(resources);
  }
  public void testVariables() throws Exception {
    Variable r1 = new Variable("var1");
    Variable r2 = new Variable("var2");
    Variable r3 = new Variable("var3");
    Set variables = new TreeSet(new VariableNameComparator());
    variables.add(r3);
    variables.add(r1);
    variables.add(r2);
    assertEquals("var1",((Variable)((TreeSet) variables).first()).getName());
View Full Code Here

public class VariableNameComparator implements Comparator {

  public int compare(Object o1, Object o2) {
    if(o1 != null && o2 != null && o1 instanceof Variable && o2 instanceof Variable) {
      Variable r1 = (Variable) o1;
      Variable r2 = (Variable) o2;
      if(r1.getName()!=null && r2.getName()!=null)
        return r1.getName().compareTo(r2.getName());
    }
    return 0;
  }
View Full Code Here

    vsi = new VariableServiceImpl();
  }

  public void testNameAlreadyInUse() {
    List variables = new ArrayList();
    Variable variable = new Variable("var1","val1");
    variables.add(variable);
    variables.add(new Variable("var2","val2"));
    variables.add(new Variable("var3","val3"));
    assertFalse("1",vsi.nameAlreadyInUse(variable.getId(),"var1",variables));
    assertTrue("2",vsi.nameAlreadyInUse("","var1",variables));
    assertTrue("3",vsi.nameAlreadyInUse(" ","var1",variables));
    assertTrue("4",vsi.nameAlreadyInUse(null,"var1",variables));
    assertTrue("5",vsi.nameAlreadyInUse(variable.getId(),"var2",variables));
  }
View Full Code Here

TOP

Related Classes of fr.norsys.mapper.console.model.Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.