Package org.apache.sqoop.model

Examples of org.apache.sqoop.model.MForm


    inputs.add(input);

    input = new MEnumInput("f.Enum", false, new String[] {"YES", "NO"});
    inputs.add(input);

    forms.add(new MForm("f", inputs));
    return forms;
  }
View Full Code Here


        }
      }
      mInputs.add(mInput);
    }

    MForm mForm = new MForm((String) form.get(FORM_NAME), mInputs);
    mForm.setPersistenceId((Long) form.get(ID));
    return mForm;
  }
View Full Code Here

    for (MForm form : original) {
      formMap.put(form.getName(), form);
    }
    for (MForm form : target) {
      List<MInput<?>> inputs = form.getInputs();
      MForm originalForm = formMap.get(form.getName());
      for (MInput input : inputs) {
        MInput originalInput = originalForm.getInput(input.getName());
        input.setValue(originalInput.getValue());
      }
    }
  }
View Full Code Here

      print(type);
      print(" %s ", resourceString(Constants.RES_FORMDISPLAYER_FORM));
      print(findx++);
      println(":");

      MForm form = fiter.next();
      print("      %s: ", resourceString(Constants.RES_FORMDISPLAYER_NAME));
      println(form.getName());

      // Label
      print("      %s: ", resourceString(Constants.RES_FORMDISPLAYER_LABEL));
      println(bundle.getString(form.getLabelKey()));

      // Help text
      print("      %s: ", resourceString(Constants.RES_FORMDISPLAYER_HELP));
      println(bundle.getString(form.getHelpKey()));

      List<MInput<?>> inputs = form.getInputs();
      Iterator<MInput<?>> iiter = inputs.iterator();
      int iindx = 1;
      while (iiter.hasNext()) {
        print("      %s ", resourceString(Constants.RES_FORMDISPLAYER_INPUT));
        print(iindx++);
View Full Code Here

    inputs = new LinkedList<MInput<?>>();
    input = new MStringInput("I1", false, (short)30);
    inputs.add(input);
    input = new MMapInput("I2", false);
    inputs.add(input);
    forms.add(new MForm("F1", inputs));

    inputs = new LinkedList<MInput<?>>();
    input = new MStringInput("I3", false, (short)30);
    inputs.add(input);
    input = new MMapInput("I4", false);
    inputs.add(input);
    forms.add(new MForm("F2", inputs));

    return forms;
  }
View Full Code Here

      String formName = rsetForm.getString(4);
      String formType = rsetForm.getString(5);
      int formIndex = rsetForm.getInt(6);
      List<MInput<?>> formInputs = new ArrayList<MInput<?>>();

      MForm mf = new MForm(formName, formInputs);
      mf.setPersistenceId(formId);

      inputFetchStmt.setLong(formPosition, formId);

      ResultSet rsetInput = inputFetchStmt.executeQuery();
      while (rsetInput.next()) {
        long inputId = rsetInput.getLong(1);
        String inputName = rsetInput.getString(2);
        long inputForm = rsetInput.getLong(3);
        short inputIndex = rsetInput.getShort(4);
        String inputType = rsetInput.getString(5);
        boolean inputSensitivity = rsetInput.getBoolean(6);
        short inputStrLength = rsetInput.getShort(7);
        String inputEnumValues = rsetInput.getString(8);
        String value = rsetInput.getString(9);

        MInputType mit = MInputType.valueOf(inputType);

        MInput input = null;
        switch (mit) {
        case STRING:
          input = new MStringInput(inputName, inputSensitivity, inputStrLength);
          break;
        case MAP:
          input = new MMapInput(inputName, inputSensitivity);
          break;
        case BOOLEAN:
          input = new MBooleanInput(inputName, inputSensitivity);
          break;
        case INTEGER:
          input = new MIntegerInput(inputName, inputSensitivity);
          break;
        case ENUM:
          input = new MEnumInput(inputName, inputSensitivity, inputEnumValues.split(","));
          break;
        default:
          throw new SqoopException(DerbyRepoError.DERBYREPO_0006,
              "input-" + inputName + ":" + inputId + ":"
              + "form-" + inputForm + ":" + mit.name());
        }

        // Set persistent ID
        input.setPersistenceId(inputId);

        // Set value
        if(value == null) {
          input.setEmpty();
        } else {
          input.restoreFromUrlSafeValueString(value);
        }

        if (mf.getInputs().size() != inputIndex) {
          throw new SqoopException(DerbyRepoError.DERBYREPO_0009,
            "form: " + mf
            + "; input: " + input
            + "; index: " + inputIndex
            + "; expected: " + mf.getInputs().size()
          );
        }

        mf.getInputs().add(input);
      }

      if (mf.getInputs().size() == 0) {
        throw new SqoopException(DerbyRepoError.DERBYREPO_0008,
          "connector-" + formConnectorId
          + "; form: " + mf
        );
      }
View Full Code Here

    for (MForm form : original) {
      formMap.put(form.getName(), form);
    }
    for (MForm form : target) {
      List<MInput<?>> inputs = form.getInputs();
      MForm originalForm = formMap.get(form.getName());
      for (MInput input : inputs) {
        try {
          MInput originalInput = originalForm.getInput(input.getName());
          input.setValue(originalInput.getValue());
        } catch (SqoopException ex) {
          LOG.warn("Input: " + input.getName() + " not present in old " +
            "connector. So it will not be transferred by the upgrader.");
        }
View Full Code Here

  }

  public static MConnectionForms getConnectionForms() {
    List<MInput<?>> inputs;
    MStringInput input;
    MForm form;
    List<MForm> connectionForms = new ArrayList<MForm>();
    inputs = new ArrayList<MInput<?>>();

    input = new MStringInput("url", false, (short) 10);
    input.setPersistenceId(1);
    inputs.add(input);

    input = new MStringInput("username", false, (short) 10);
    input.setPersistenceId(2);
    input.setValue("test");
    inputs.add(input);

    input = new MStringInput("password", true, (short) 10);
    input.setPersistenceId(3);
    input.setValue("test");
    inputs.add(input);

    form = new MForm("connection", inputs);
    form.setPersistenceId(10);
    connectionForms.add(form);

    return new MConnectionForms(connectionForms);
  }
View Full Code Here

  }

  public static MJobForms getJobForms(MJob.Type type) {
    List<MInput<?>> inputs;
    MStringInput input;
    MForm form;
    List<MForm> jobForms = new ArrayList<MForm>();

    inputs = new ArrayList<MInput<?>>();

    input = new MStringInput("A", false, (short) 10);
    input.setPersistenceId(4);
    inputs.add(input);

    input = new MStringInput("B", false, (short) 10);
    input.setPersistenceId(5);
    inputs.add(input);

    input = new MStringInput("C", false, (short) 10);
    input.setPersistenceId(6);
    inputs.add(input);

    form = new MForm("Z", inputs);
    form.setPersistenceId(11);
    jobForms.add(form);

    inputs = new ArrayList<MInput<?>>();

    input = new MStringInput("D", false, (short) 10);
    input.setPersistenceId(7);
    inputs.add(input);

    input = new MStringInput("E", false, (short) 10);
    input.setPersistenceId(8);
    inputs.add(input);

    input = new MStringInput("F", false, (short) 10);
    input.setPersistenceId(9);
    inputs.add(input);

    form = new MForm("connection", inputs);
    form.setPersistenceId(12);
    jobForms.add(form);

    return new MJobForms(type, jobForms);
  }
View Full Code Here

    // Inserted values
    Map<String, String> map = new HashMap<String, String>();
    map.put("A", "B");

    // Fill form with all values
    MForm form = getForm();
    form.getStringInput("String").setValue("A");
    form.getMapInput("Map").setValue(map);
    form.getIntegerInput("Integer").setValue(1);
    form.getBooleanInput("Boolean").setValue(true);
    form.getEnumInput("Enum").setValue("YES");

    // Serialize that into JSON
    JSONObject jsonObject = FormSerialization.extractForm(form, false);
    assertNotNull(jsonObject);

    // Exchange the data on string level
    String serializedJson = jsonObject.toJSONString();
    JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);

    // And retrieve back from JSON representation
    MForm retrieved = FormSerialization.restoreForm(retrievedJson);

    // Verify all expected values
    assertEquals("A", retrieved.getStringInput("String").getValue());
    assertEquals(map, retrieved.getMapInput("Map").getValue());
    assertEquals(1, (int)retrieved.getIntegerInput("Integer").getValue());
    assertEquals(true, retrieved.getBooleanInput("Boolean").getValue());
    assertEquals("YES", retrieved.getEnumInput("Enum").getValue());
  }
View Full Code Here

TOP

Related Classes of org.apache.sqoop.model.MForm

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.