Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Partition
Commits
0243115c
Commit
0243115c
authored
Sep 29, 2020
by
neelesh thakur
Browse files
add id for list all workflows
parent
663159ac
Pipeline
#10432
passed with stages
in 12 minutes and 56 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/persistence/CloudTableStore.java
View file @
0243115c
...
...
@@ -10,8 +10,6 @@ import org.springframework.stereotype.Component;
@Component
public
class
CloudTableStore
{
private
final
String
PARTITION_KEY
=
"PartitionKey"
;
@Autowired
private
CloudTable
cloudTableClient
;
...
...
@@ -28,10 +26,10 @@ public class CloudTableStore {
}
}
public
Iterable
<?
extends
TableEntity
>
queryBy
PartitionId
(
final
Class
<?
extends
TableEntity
>
clazzType
,
String
value
)
{
public
Iterable
<?
extends
TableEntity
>
queryBy
Key
(
final
Class
<?
extends
TableEntity
>
clazzType
,
final
String
key
,
final
String
value
)
{
String
partitionFilter
=
TableQuery
.
generateFilterCondition
(
PARTITION_KEY
,
key
,
TableQuery
.
QueryComparisons
.
EQUAL
,
value
);
...
...
@@ -41,6 +39,29 @@ public class CloudTableStore {
return
this
.
cloudTableClient
.
execute
(
partitionQuery
);
}
public
Iterable
<?
extends
TableEntity
>
queryByCompoundKey
(
final
Class
<?
extends
TableEntity
>
clazzType
,
final
String
rowKey
,
final
String
rowValue
,
final
String
valueKey
,
final
String
value
)
{
String
rowFilter
=
TableQuery
.
generateFilterCondition
(
rowKey
,
TableQuery
.
QueryComparisons
.
EQUAL
,
rowValue
);
String
valueFilter
=
TableQuery
.
generateFilterCondition
(
valueKey
,
TableQuery
.
QueryComparisons
.
EQUAL
,
value
);
String
combinedFilter
=
TableQuery
.
combineFilters
(
rowFilter
,
TableQuery
.
Operators
.
AND
,
valueFilter
);
TableQuery
<?
extends
TableEntity
>
partitionQuery
=
TableQuery
.
from
(
clazzType
)
.
where
(
combinedFilter
);
return
this
.
cloudTableClient
.
execute
(
partitionQuery
);
}
public
void
insertBatchEntities
(
TableBatchOperation
batchOperation
)
{
try
{
this
.
cloudTableClient
.
execute
(
batchOperation
);
...
...
provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/persistence/PartitionTableStore.java
View file @
0243115c
...
...
@@ -15,6 +15,13 @@ import java.util.Map;
@Component
public
class
PartitionTableStore
{
private
final
static
String
ID
=
"id"
;
private
final
static
String
VALUE
=
"value"
;
private
final
static
String
SENSITIVE
=
"sensitive"
;
private
final
String
PARTITION_KEY
=
"PartitionKey"
;
private
final
String
ROW_KEY
=
"RowKey"
;
@Autowired
private
CloudTableStore
cloudTableStore
;
...
...
@@ -22,6 +29,7 @@ public class PartitionTableStore {
Map
<
String
,
Property
>
requestProperties
=
partitionInfo
.
getProperties
();
TableBatchOperation
batchOperation
=
new
TableBatchOperation
();
batchOperation
.
insertOrReplace
(
this
.
getIdPartitionEntity
(
partitionId
));
for
(
Map
.
Entry
<
String
,
Property
>
entry
:
requestProperties
.
entrySet
())
{
String
key
=
entry
.
getKey
();
Property
property
=
entry
.
getValue
();
...
...
@@ -32,8 +40,8 @@ public class PartitionTableStore {
if
(
property
.
isSensitive
())
{
property
.
setValue
(
this
.
getTenantSafeSecreteId
(
partitionId
,
String
.
valueOf
(
property
.
getValue
())));
}
properties
.
put
(
"value"
,
new
EntityProperty
(
String
.
valueOf
(
property
.
getValue
())));
properties
.
put
(
"sensitive"
,
new
EntityProperty
(
property
.
isSensitive
()));
properties
.
put
(
VALUE
,
new
EntityProperty
(
String
.
valueOf
(
property
.
getValue
())));
properties
.
put
(
SENSITIVE
,
new
EntityProperty
(
property
.
isSensitive
()));
partitionEntity
.
setProperties
(
properties
);
batchOperation
.
insertOrReplace
(
partitionEntity
);
}
...
...
@@ -42,15 +50,14 @@ public class PartitionTableStore {
}
public
boolean
partitionExists
(
String
partitionId
)
{
List
<
PartitionEntity
>
partitionEntities
=
this
.
queryByPartitionId
(
partitionId
);
return
!
partitionEntities
.
isEmpty
();
List
<
PartitionEntity
>
partitionEntities
=
this
.
queryById
(
partitionId
);
return
partitionEntities
.
size
()
==
1
;
}
public
Map
<
String
,
Property
>
getPartition
(
String
partitionId
)
{
Map
<
String
,
Property
>
out
=
new
HashMap
<>();
List
<
PartitionEntity
>
partitionEntities
=
this
.
query
ByPartitionId
(
partitionId
);
List
<
PartitionEntity
>
partitionEntities
=
this
.
getAll
ByPartitionId
(
partitionId
);
if
(
partitionEntities
.
isEmpty
())
{
return
out
;
}
...
...
@@ -58,33 +65,55 @@ public class PartitionTableStore {
for
(
PartitionEntity
pe
:
partitionEntities
)
{
Property
property
=
Property
.
builder
().
build
();
HashMap
<
String
,
EntityProperty
>
properties
=
pe
.
getProperties
();
if
(
properties
.
containsKey
(
"sensitive"
))
{
property
.
setSensitive
(
properties
.
get
(
"sensitive"
).
getValueAsBoolean
());
if
(
properties
.
containsKey
(
SENSITIVE
))
{
property
.
setSensitive
(
properties
.
get
(
SENSITIVE
).
getValueAsBoolean
());
}
if
(
properties
.
containsKey
(
"value"
))
{
property
.
setValue
(
properties
.
get
(
"value"
).
getValueAsString
());
if
(
properties
.
containsKey
(
VALUE
))
{
property
.
setValue
(
properties
.
get
(
VALUE
).
getValueAsString
());
}
out
.
put
(
pe
.
getRowKey
(),
property
);
}
return
out
;
}
public
List
<
PartitionEntity
>
queryByPartitionId
(
String
partitionId
)
{
public
void
deletePartition
(
String
partitionId
)
{
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByKey
(
PartitionEntity
.
class
,
PARTITION_KEY
,
partitionId
);
for
(
PartitionEntity
tableEntity
:
results
)
{
this
.
cloudTableStore
.
deleteCloudTableEntity
(
PartitionEntity
.
class
,
tableEntity
.
getPartitionKey
(),
tableEntity
.
getRowKey
());
}
}
private
List
<
PartitionEntity
>
queryById
(
String
partitionId
)
{
List
<
PartitionEntity
>
out
=
new
ArrayList
<>();
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByPartitionId
(
PartitionEntity
.
class
,
partitionId
);
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByCompoundKey
(
PartitionEntity
.
class
,
ROW_KEY
,
ID
,
VALUE
,
partitionId
);
for
(
PartitionEntity
tableEntity
:
results
)
{
tableEntity
.
setPartitionId
(
tableEntity
.
getPartitionKey
());
tableEntity
.
setName
(
tableEntity
.
getRowKey
());
out
.
add
(
tableEntity
);
}
return
out
;
}
public
void
deletePartition
(
String
partitionId
)
{
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByPartitionId
(
PartitionEntity
.
class
,
partitionId
);
private
List
<
PartitionEntity
>
getAllByPartitionId
(
String
partitionId
)
{
List
<
PartitionEntity
>
out
=
new
ArrayList
<>();
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByKey
(
PartitionEntity
.
class
,
PARTITION_KEY
,
partitionId
);
for
(
PartitionEntity
tableEntity
:
results
)
{
this
.
cloudTableStore
.
deleteCloudTableEntity
(
PartitionEntity
.
class
,
tableEntity
.
getPartitionKey
(),
tableEntity
.
getRowKey
());
tableEntity
.
setPartitionId
(
tableEntity
.
getPartitionKey
());
tableEntity
.
setName
(
tableEntity
.
getRowKey
());
out
.
add
(
tableEntity
);
}
return
out
;
}
private
PartitionEntity
getIdPartitionEntity
(
String
partitionId
)
{
PartitionEntity
partitionEntity
=
new
PartitionEntity
(
partitionId
,
ID
);
HashMap
<
String
,
EntityProperty
>
properties
=
new
HashMap
<>();
properties
.
put
(
VALUE
,
new
EntityProperty
(
partitionId
));
properties
.
put
(
SENSITIVE
,
new
EntityProperty
(
false
));
partitionEntity
.
setProperties
(
properties
);
return
partitionEntity
;
}
private
String
getTenantSafeSecreteId
(
String
partitionId
,
String
secreteName
)
{
...
...
testing/partition-test-core/src/main/java/org/opengroup/osdu/partition/api/descriptor/CreatePartitionDescriptor.java
View file @
0243115c
...
...
@@ -36,10 +36,9 @@ public class CreatePartitionDescriptor extends RestDescriptor {
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"{\n"
);
sb
.
append
(
" \"properties\": {"
)
.
append
(
"\"id\": \""
).
append
(
this
.
arg
()).
append
(
"\","
)
.
append
(
"\"elasticPassword\": {\"sensitive\":true,\"value\":\"test-password\"},"
)
.
append
(
"\"serviceBusConnection\": {\"sensitive\":true,\"value\":\"test-service-bus-connection\"},"
)
.
append
(
"\"co
smosConnection
\": \"
test-cosmos-connection
\""
)
.
append
(
"\"co
mplianceRuleSet
\":
{
\"
value\":\"shared
\"
}
"
)
.
append
(
"}\n"
)
.
append
(
"}"
);
return
sb
.
toString
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment