Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qwazr.database;
import com.qwazr.database.model.ColumnDefinition;
import com.qwazr.database.model.TableDefinition;
import com.qwazr.database.model.TableRequest;
import com.qwazr.database.model.TableRequestResult;
import com.qwazr.database.model.TableStatus;
import com.qwazr.database.store.KeyStore;
import com.qwazr.server.RemoteService;
import com.qwazr.server.client.JsonClient;
import com.qwazr.utils.StringUtils;
import javax.ws.rs.NotAcceptableException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
public class TableSingleClient extends JsonClient implements TableServiceInterface {
private final WebTarget tableTarget;
public TableSingleClient(final RemoteService remote) {
super(remote);
tableTarget = client.target(remote.serviceAddress).path("table");
}
@Override
public SortedSet list() {
return tableTarget.request(MediaType.APPLICATION_JSON).get(sortedSetStringType);
}
@Override
public TableDefinition createTable(final String tableName, final KeyStore.Impl storeImplementation) {
WebTarget target = tableTarget.path(tableName);
if (storeImplementation != null)
target = target.queryParam("implementation", storeImplementation);
return target.request(MediaType.APPLICATION_JSON).post(Entity.json(null), TableDefinition.class);
}
@Override
public TableStatus getTableStatus(final String tableName) {
return tableTarget.path(tableName).request(MediaType.APPLICATION_JSON).get(TableStatus.class);
}
@Override
public Boolean deleteTable(final String tableName) {
return tableTarget.path(tableName).request(MediaType.APPLICATION_JSON).delete(Boolean.class);
}
@Override
public Map getColumns(final String tableName) {
return tableTarget.path(tableName)
.path("column")
.request(MediaType.APPLICATION_JSON)
.get(ColumnDefinition.mapStringColumnType);
}
@Override
public ColumnDefinition getColumn(final String tableName, final String columnName) {
return tableTarget.path(tableName)
.path("column")
.path(columnName)
.request(MediaType.APPLICATION_JSON)
.get(ColumnDefinition.class);
}
@Override
public List