aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java12
-rw-r--r--src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java12
-rw-r--r--src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java4
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file2
-rw-r--r--ui-react/src/components/dialogs/Policy/ViewAllPolicies.js87
5 files changed, 100 insertions, 17 deletions
diff --git a/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
index bd3a1cb13..4ad47422c 100644
--- a/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
+++ b/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,6 +23,8 @@
package org.onap.policy.clamp.clds.tosca.update.execution.cds;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -31,6 +33,7 @@ import java.util.Set;
import org.onap.policy.clamp.clds.tosca.ToscaSchemaConstants;
import org.onap.policy.clamp.clds.tosca.ToscaSchemaConstants;
import org.onap.policy.clamp.clds.tosca.update.execution.ToscaMetadataProcess;
+import org.onap.policy.clamp.clds.tosca.update.execution.target.ToscaMetadataTargetProcess;
import org.onap.policy.clamp.loop.service.Service;
@@ -39,8 +42,15 @@ import org.onap.policy.clamp.loop.service.Service;
*/
public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
+ private static final EELFLogger logger =
+ EELFManager.getInstance().getLogger(ToscaMetadataCdsProcess.class);
+
@Override
public void executeProcess(String parameters, JsonObject childObject, Service serviceModel) {
+ if (serviceModel == null) {
+ logger.info("serviceModel is null, therefore the ToscaMetadataCdsProcess is skipped");
+ return;
+ }
switch (parameters) {
case "actor":
JsonArray jsonArray = new JsonArray();
diff --git a/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java b/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java
index f4ca9909b..dcfd0594f 100644
--- a/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java
+++ b/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,10 @@
package org.onap.policy.clamp.clds.tosca.update.execution.target;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonObject;
+import org.onap.policy.clamp.clds.tosca.update.execution.ToscaMetadataExecutor;
import org.onap.policy.clamp.clds.tosca.update.execution.ToscaMetadataProcess;
import org.onap.policy.clamp.loop.service.Service;
import org.onap.policy.clamp.policy.operational.OperationalPolicyRepresentationBuilder;
@@ -33,8 +36,15 @@ import org.onap.policy.clamp.policy.operational.OperationalPolicyRepresentationB
*/
public class ToscaMetadataTargetProcess extends ToscaMetadataProcess {
+ private static final EELFLogger logger =
+ EELFManager.getInstance().getLogger(ToscaMetadataTargetProcess.class);
+
@Override
public void executeProcess(String parameters, JsonObject childObject, Service serviceModel) {
+ if (serviceModel == null) {
+ logger.info("serviceModel is null, therefore the ToscaMetadataTargetProcess is skipped");
+ return;
+ }
childObject.add("anyOf", OperationalPolicyRepresentationBuilder.createAnyOfArray(serviceModel, false));
}
}
diff --git a/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java b/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
index 5a9720a00..74fd8e5fd 100644
--- a/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
+++ b/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
@@ -118,8 +118,8 @@ public class ToscaConverterToJsonSchema {
JsonArray requirements = new JsonArray();
ToscaElement toParse = components.get(nameComponent);
//Check for a father component, and launch the same process
- if (!toParse.getDerivedFrom().equals("tosca.datatypes.Root")
- && !toParse.getDerivedFrom().equals("tosca.policies.Root")) {
+ if (!"tosca.datatypes.Root".equals(toParse.getDerivedFrom())
+ && !"tosca.policies.Root".equals(toParse.getDerivedFrom())) {
requirements.addAll(getRequirements(toParse.getDerivedFrom()));
}
//Each property is checked, and add to the requirement array if it's required
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file
index a44435111..a00692971 100644
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file
@@ -61,7 +61,7 @@ data_types:
type: policy.data.increment-sequence
required: false
policy.data.increment-sequence:
- derived_from: tosca.nodes.Root
+ derived_from: tosca.datatypes.Root
properties:
scope:
type: list
diff --git a/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js b/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js
index a93aa3534..625aeb341 100644
--- a/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js
+++ b/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js
@@ -25,13 +25,23 @@ import React, { forwardRef } from 'react'
import Button from 'react-bootstrap/Button';
import Modal from 'react-bootstrap/Modal';
import styled from 'styled-components';
-import ArrowUpward from '@material-ui/icons/ArrowUpward';
+import AddBox from '@material-ui/icons/AddBox';
+import ArrowDownward from '@material-ui/icons/ArrowDownward';
+import Check from '@material-ui/icons/Check';
import ChevronLeft from '@material-ui/icons/ChevronLeft';
import ChevronRight from '@material-ui/icons/ChevronRight';
import Clear from '@material-ui/icons/Clear';
+import DeleteOutline from '@material-ui/icons/DeleteOutline';
+import Edit from '@material-ui/icons/Edit';
+import FilterList from '@material-ui/icons/FilterList';
import FirstPage from '@material-ui/icons/FirstPage';
import LastPage from '@material-ui/icons/LastPage';
+import Remove from '@material-ui/icons/Remove';
+import SaveAlt from '@material-ui/icons/SaveAlt';
import Search from '@material-ui/icons/Search';
+import ViewColumn from '@material-ui/icons/ViewColumn';
+import FormControlLabel from '@material-ui/core/FormControlLabel';
+import Switch from '@material-ui/core/Switch';
import MaterialTable from "material-table";
import PolicyService from '../../../api/PolicyService';
import PolicyToscaService from '../../../api/PolicyToscaService';
@@ -46,6 +56,16 @@ const ModalStyled = styled(Modal)`
}
background-color: transparent;
`
+const JsonEditorDiv = styled.div`
+ margin-top: 20px;
+ background-color: ${props => props.theme.toscaTextareaBackgroundColor};
+ text-align: justify;
+ font-size: ${props => props.theme.toscaTextareaFontSize};
+ width: 100%;
+ height: 30%;
+ border: 1px solid black;
+`
+
const standardCellStyle = { border: '1px solid black' };
const cellPdpGroupStyle = { backgroundColor: '#039be5', color: '#FFF', border: '1px solid black'};
@@ -58,13 +78,9 @@ export default class ViewAllPolicies extends React.Component {
content: 'Please select a policy to display it',
selectedRow: -1,
policiesListData: [],
+ prefixGrouping: false,
policyColumnsDefinition: [
{
- title: "#", field: "index", render: rowData => rowData.tableData.id + 1,
- cellStyle: standardCellStyle,
- headerStyle: headerStyle
- },
- {
title: "Policy Name", field: "name",
cellStyle: standardCellStyle,
headerStyle: headerStyle
@@ -88,7 +104,8 @@ export default class ViewAllPolicies extends React.Component {
title: "Deployed in PDP", field: "pdpGroupInfo.pdpGroup",
cellStyle: cellPdpGroupStyle,
headerStyle: headerStyle,
- render: rowData => this.renderPdpGroupDropBox(rowData)
+ render: rowData => this.renderPdpGroupDropBox(rowData),
+ grouping: false
},
{
title: "PDP Group", field: "pdpGroupInfo.pdpGroup",
@@ -102,13 +119,23 @@ export default class ViewAllPolicies extends React.Component {
}
],
tableIcons: {
+ Add: forwardRef((props, ref) => <AddBox {...props} ref={ref} />),
+ Check: forwardRef((props, ref) => <Check {...props} ref={ref} />),
+ Clear: forwardRef((props, ref) => <Clear {...props} ref={ref} />),
+ Delete: forwardRef((props, ref) => <DeleteOutline {...props} ref={ref} />),
+ DetailPanel: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />),
+ Edit: forwardRef((props, ref) => <Edit {...props} ref={ref} />),
+ Export: forwardRef((props, ref) => <SaveAlt {...props} ref={ref} />),
+ Filter: forwardRef((props, ref) => <FilterList {...props} ref={ref} />),
FirstPage: forwardRef((props, ref) => <FirstPage {...props} ref={ref} />),
LastPage: forwardRef((props, ref) => <LastPage {...props} ref={ref} />),
NextPage: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />),
PreviousPage: forwardRef((props, ref) => <ChevronLeft {...props} ref={ref} />),
ResetSearch: forwardRef((props, ref) => <Clear {...props} ref={ref} />),
Search: forwardRef((props, ref) => <Search {...props} ref={ref} />),
- SortArrow: forwardRef((props, ref) => <ArrowUpward {...props} ref={ref} />)
+ SortArrow: forwardRef((props, ref) => <ArrowDownward {...props} ref={ref} />),
+ ThirdStateCheck: forwardRef((props, ref) => <Remove {...props} ref={ref} />),
+ ViewColumn: forwardRef((props, ref) => <ViewColumn {...props} ref={ref} />)
}
};
@@ -118,6 +145,9 @@ export default class ViewAllPolicies extends React.Component {
this.renderPdpGroupDropBox = this.renderPdpGroupDropBox.bind(this);
this.handlePdpGroupChange = this.handlePdpGroupChange.bind(this);
this.createJsonEditor = this.createJsonEditor.bind(this);
+ this.handlePrefixGrouping = this.handlePrefixGrouping.bind(this);
+ this.deletePolicy = this.deletePolicy.bind(this);
+ this.handleUpdatePolicy = this.handleUpdatePolicy.bind(this);
this.getAllPolicies();
}
@@ -136,6 +166,7 @@ export default class ViewAllPolicies extends React.Component {
}
createJsonEditor(toscaModel, editorData) {
+ document.getElementById("policy-editor").innerHTML = "";
JSONEditor.defaults.themes.myBootstrap4 = JSONEditor.defaults.themes.bootstrap4.extend({
getTab: function(text,tabId) {
var liel = document.createElement('li');
@@ -152,7 +183,8 @@ export default class ViewAllPolicies extends React.Component {
}
});
return new JSONEditor(document.getElementById("policy-editor"),
- { schema: toscaModel,
+ {
+ schema: toscaModel,
startval: editorData,
theme: 'myBootstrap4',
object_layout: 'grid',
@@ -201,6 +233,11 @@ export default class ViewAllPolicies extends React.Component {
this.props.history.push('/')
}
+ handleUpdatePolicy() {
+ this.setState({ show: false });
+ this.props.history.push('/')
+ }
+
handleOnRowClick(rowData) {
PolicyToscaService.getToscaPolicyModel(rowData["type"], rowData["type_version"]).then(respJsonPolicyTosca => {
this.setState({
@@ -212,12 +249,24 @@ export default class ViewAllPolicies extends React.Component {
});
}
+ handlePrefixGrouping(event) {
+ this.setState({prefixGrouping: event.target.checked});
+ };
+
+ deletePolicy(event, rowData) {
+ return null;
+ }
+
render() {
return (
- <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false}>
+ <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false}>
<Modal.Header closeButton>
</Modal.Header>
<Modal.Body>
+ <FormControlLabel
+ control={<Switch checked={this.state.prefixGrouping} onChange={this.handlePrefixGrouping} />}
+ label="Group by prefix"
+ />
<MaterialTable
title={"View All Policies in Policy Engine"}
data={this.state.policiesListData}
@@ -225,13 +274,27 @@ export default class ViewAllPolicies extends React.Component {
icons={this.state.tableIcons}
onRowClick={(event, rowData) => {this.handleOnRowClick(rowData)}}
options={{
+ grouping: true,
+ exportButton: true,
headerStyle:rowHeaderStyle,
rowStyle: rowData => ({
- backgroundColor: (this.state.selectedRow !== -1 && this.state.selectedRow === rowData.tableData.id) ? '#EEE' : '#FFF'
+ backgroundColor: (this.state.selectedRow !== -1 && this.state.selectedRow === rowData.tableData.id) ? '#EEE' : '#FFF'
})
}}
+ actions={[
+ {
+ icon: forwardRef((props, ref) => <DeleteOutline {...props} ref={ref} />),
+ tooltip: 'Delete Policy',
+ onClick: (event, rowData) => this.deletePolicy(event, rowData)
+ }
+ ]}
+
/>
- <div id="policy-editor" />
+ <JsonEditorDiv>
+ <h5>Policy Properties Editor</h5>
+ <div id="policy-editor" title="Policy Properties"/>
+ <Button variant="secondary" onClick={this.handleUpdatePolicy}>Update</Button>
+ </JsonEditorDiv>
</Modal.Body>
<Modal.Footer>
<Button variant="secondary" onClick={this.handleClose}>Close</Button>