diff options
author | Thomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com> | 2018-07-16 16:41:20 -0400 |
---|---|---|
committer | Thomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com> | 2018-07-16 16:41:20 -0400 |
commit | 9b6efbd93a12c858a0d2643013217ec3d6c3a46d (patch) | |
tree | baf6c8de19daba3f4dc2b7761bda4cb858ba90e4 /src/main/java/org/onap/music/datastore | |
parent | 5a28a331688c5578fef9c64d462d07cbae6797da (diff) |
various Updates
Q-api,
triggers,
conductor conditional updates.
Bug fixes
Change-Id: Iec392309787cd90f0a2827a2955399723640e800
Issue-ID: MUSIC-93
Signed-off-by: Thomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/datastore')
4 files changed, 99 insertions, 5 deletions
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStore.java b/src/main/java/org/onap/music/datastore/MusicDataStore.java index e9356f9d..563e07f5 100644 --- a/src/main/java/org/onap/music/datastore/MusicDataStore.java +++ b/src/main/java/org/onap/music/datastore/MusicDataStore.java @@ -24,6 +24,7 @@ package org.onap.music.datastore; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; @@ -51,6 +52,7 @@ import com.datastax.driver.core.TableMetadata; import com.datastax.driver.core.exceptions.AlreadyExistsException; import com.datastax.driver.core.exceptions.InvalidQueryException; import com.datastax.driver.core.exceptions.NoHostAvailableException; +import com.sun.jersey.core.util.Base64; /** * @author nelson24 @@ -259,6 +261,12 @@ public class MusicDataStore { return null; } } + + public byte[] getBlobValue(Row row, String colName, DataType colType) { + ByteBuffer bb = row.getBytes(colName); + byte[] data = bb.array(); + return data; + } public boolean doesRowSatisfyCondition(Row row, Map<String, Object> condition) throws Exception { ColumnDefinitions colInfo = row.getColumnDefinitions(); @@ -288,9 +296,15 @@ public class MusicDataStore { ColumnDefinitions colInfo = row.getColumnDefinitions(); HashMap<String, Object> resultOutput = new HashMap<String, Object>(); for (Definition definition : colInfo) { - if (!definition.getName().equals("vector_ts")) - resultOutput.put(definition.getName(), + if (!definition.getName().equals("vector_ts")) { + if(definition.getType().toString().toLowerCase().contains("blob")) { + resultOutput.put(definition.getName(), + getBlobValue(row, definition.getName(), definition.getType())); + } + else + resultOutput.put(definition.getName(), getColValue(row, definition.getName(), definition.getType())); + } } resultMap.put("row " + counter, resultOutput); counter++; @@ -326,10 +340,15 @@ public class MusicDataStore { + queryObject.getValues()); PreparedStatement preparedInsert = null; try { - preparedInsert = session.prepare(queryObject.getQuery()); + + preparedInsert = session.prepare(queryObject.getQuery()); + } catch(InvalidQueryException iqe) { - logger.error(EELFLoggerDelegate.errorLogger, iqe.getMessage()); + logger.error(EELFLoggerDelegate.errorLogger, iqe.getMessage(),AppMessages.QUERYERROR, ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR); throw new MusicQueryException(iqe.getMessage()); + }catch(Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.QUERYERROR, ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR); + throw new MusicQueryException(e.getMessage()); } try { diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JSONObject.java b/src/main/java/org/onap/music/datastore/jsonobjects/JSONObject.java new file mode 100644 index 00000000..8de0a2cd --- /dev/null +++ b/src/main/java/org/onap/music/datastore/jsonobjects/JSONObject.java @@ -0,0 +1,37 @@ +package org.onap.music.datastore.jsonobjects; +/* + * ============LICENSE_START========================================== + * org.onap.music + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property + * =================================================================== + * 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. + * + * ============LICENSE_END============================================= + * ==================================================================== + */ + + +public class JSONObject { + + private String data; + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + +} diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java index a58552c6..9630abe0 100644 --- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java +++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java @@ -43,7 +43,18 @@ public class JsonInsert implements Serializable { private String timestamp; private Map<String, Object> row_specification; private Map<String, String> consistencyInfo; - + private byte[] data; + private Map<String, byte[]> objectMap; + + @ApiModelProperty(value = "objectMap") + public Map<String, byte[]> getObjectMap() { + return objectMap; + } + + public void setObjectMap(Map<String, byte[]> objectMap) { + this.objectMap = objectMap; + } + @ApiModelProperty(value = "keyspace") public String getKeyspaceName() { return keyspaceName; diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonTable.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonTable.java index 5d508adb..2e0a5ded 100644 --- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonTable.java +++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonTable.java @@ -38,6 +38,9 @@ public class JsonTable { private Map<String, Object> properties; private String primaryKey; private String sortingKey; + private String partitionKey; + private String clusteringKey; + private String filteringKey; private String clusteringOrder; private Map<String, String> consistencyInfo; @@ -113,5 +116,29 @@ public class JsonTable { this.primaryKey = primaryKey; } + public String getClusteringKey() { + return clusteringKey; + } + + public void setClusteringKey(String clusteringKey) { + this.clusteringKey = clusteringKey; + } + + public String getFilteringKey() { + return filteringKey; + } + + public void setFilteringKey(String filteringKey) { + this.filteringKey = filteringKey; + } + + public String getPartitionKey() { + return partitionKey; + } + + public void setPartitionKey(String partitionKey) { + this.partitionKey = partitionKey; + } + } |