@Test
 public void testChangeNameOnExistingDataSources() throws Exception {
   sm.register("file", super.getAnyNonSpatialResource());
   DataSource ds = dsf.getDataSourceFromSQL("select * from file;");
   sm.rename(ds.getName(), "sql");
   DataSource ds2 = dsf.getDataSource("sql");
   assertEquals(ds.getName(), ds2.getName());
 }
Example #2
0
  @Override
  public void deleteDataSource(final DataSource dataSource, final AsyncCallback<Boolean> callback) {

    AddressBinding address = dsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), dataSource.getName());

    ModelNode operation = dataSourceAdapter.fromEntity(dataSource);
    operation.get(OP).set(REMOVE);
    operation.get(ADDRESS).set(addressModel.get(ADDRESS));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {
            boolean wasSuccessful = responseIndicatesSuccess(result);
            callback.onSuccess(wasSuccessful);
          }
        });
  }
Example #3
0
  @Override
  public void createDataSource(
      final DataSource datasource, final AsyncCallback<ResponseWrapper<Boolean>> callback) {

    AddressBinding address = dsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), datasource.getName());

    ModelNode operation = dataSourceAdapter.fromEntity(datasource);
    operation.get(OP).set(ADD);
    operation.get(ADDRESS).set(addressModel.get(ADDRESS));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode modelNode = result.get();
            boolean wasSuccessful = modelNode.get(OUTCOME).asString().equals(SUCCESS);

            callback.onSuccess(new ResponseWrapper<Boolean>(wasSuccessful, modelNode));
          }
        });
  }
Example #4
0
 static void zza(DataSource datasource, Parcel parcel, int i) {
   int j = zzb.zzak(parcel);
   zzb.zza(parcel, 1, datasource.getDataType(), i, false);
   zzb.zzc(parcel, 1000, datasource.getVersionCode());
   zzb.zza(parcel, 2, datasource.getName(), false);
   zzb.zzc(parcel, 3, datasource.getType());
   zzb.zza(parcel, 4, datasource.getDevice(), i, false);
   zzb.zza(parcel, 5, datasource.zzrF(), i, false);
   zzb.zza(parcel, 6, datasource.getStreamName(), false);
   zzb.zzH(parcel, j);
 }
Example #5
0
  @Test
  public void testNameAndID() {
    Map<String, Object> raw = new HashMap<String, Object>();
    raw.put("id", "abcdef");
    raw.put("name", "MyDS");

    DataSource dataSource = new DataSource(raw, mock(ApiClient.class));

    assertEquals(dataSource.getId(), raw.get("id"));
    assertEquals(dataSource.getName(), raw.get("name"));
  }
  @Test
  public void testRemoveDataSources() throws Exception {
    sm.register("temp", super.getAnyNonSpatialResource());

    DataSource d = dsf.getDataSource("temp");
    sm.remove(d.getName());

    try {
      dsf.getDataSource("temp");
      fail();
    } catch (NoSuchTableException e) {
    }
  }
 public String toString(boolean detailed) {
   if (type == ConnectionType.DIRECT) {
     return String.format("%s(%s) DIRECT TO %s", name, liveness(), ds.toString());
   } else if (type == ConnectionType.CLUSTER) {
     StringBuilder builder = new StringBuilder();
     builder
         .append(name)
         .append('(')
         .append(liveness())
         .append(") VIA CLUSTER TO ")
         .append(connection.toString());
     return builder.toString();
   } else if (type == ConnectionType.CONNECTOR) {
     return String.format("%s(%s) CONNECTOR TO HOST %s", name, liveness(), getContext());
   } else if (type == ConnectionType.BRIDGED) {
     return name + " BRIDGED to " + ds != null ? ds.getName() : "null";
   } else {
     CLUtils.println(String.format("no connection status logic for type %s", type));
     return "UNKNOWN";
   }
 }
Example #8
0
  @Override
  public void enableDataSource(
      DataSource dataSource,
      boolean doEnable,
      final AsyncCallback<ResponseWrapper<Boolean>> callback) {

    final String opName = doEnable ? "enable" : "disable";

    AddressBinding address = dsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), dataSource.getName());

    ModelNode operation = dataSourceAdapter.fromEntity(dataSource);
    operation.get(OP).set(opName);
    operation.get(ADDRESS).set(addressModel.get(ADDRESS));

    if (!doEnable) operation.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);

    // System.out.println(operation);

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {

            ModelNode modelNode = result.get();
            ResponseWrapper<Boolean> response =
                new ResponseWrapper<Boolean>(
                    modelNode.get(OUTCOME).asString().equals(SUCCESS), modelNode);

            callback.onSuccess(response);
          }
        });
  }
 /**
  * Gets the title
  *
  * @return The title
  */
 public String getTitle() {
   return title == null ? (xData.getName() + " : " + yData.getName()) : title;
 }
 public LogicalDataNodeBuilder addContribution(DataSource dataSource, DataNode dataNode) {
   LogicalContributionImpl contribution = new LogicalContributionImpl(dataSource, dataNode);
   contributions.put(dataSource.getName(), contribution);
   return this;
 }
Example #11
0
 public String getDataSourceName() {
   return dataSource.getName();
 }
Example #12
0
 @Test
 public void testOperationDataSourceName() throws Throwable {
   sm.register("temp", super.getAnyNonSpatialResource());
   DataSource d = dsf.getDataSourceFromSQL("select * from temp;");
   assertNotNull(dsf.getDataSource(d.getName()));
 }
 /**
  * Return the name of the data object. If this DataHandler was created with a DataSource, this
  * method calls through to the <code>DataSource.getName</code> method, otherwise it returns
  * <i>null</i>.
  *
  * @return the name of the object
  */
 public String getName() {
   if (dataSource != null) return dataSource.getName();
   else return null;
 }