diff options
author | hekeguang <hekeguang@chinamobile.com> | 2022-08-19 15:20:44 +0800 |
---|---|---|
committer | hekeguang <hekeguang@chinamobile.com> | 2022-08-19 15:21:22 +0800 |
commit | 235aa1c823235f98ee9564e717e77ca068c2b1f1 (patch) | |
tree | 6f14b10bda4b30d4d53743e8b1395e910ecf4d02 /intentanalysis | |
parent | 031d49919a7b7dfd53b760619f87e79a57419ba9 (diff) |
Modify intent base code.
Issue-ID: USECASEUI-696
Change-Id: I4d12d19757a30a1cc4b2a3a2f1f087bac91aa2c6
Signed-off-by: hekeguang <hekeguang@chinamobile.com>
Diffstat (limited to 'intentanalysis')
24 files changed, 662 insertions, 29 deletions
diff --git a/intentanalysis/pom.xml b/intentanalysis/pom.xml index e05095c..0c34071 100644 --- a/intentanalysis/pom.xml +++ b/intentanalysis/pom.xml @@ -186,6 +186,16 @@ <artifactId>fastjson</artifactId> <version>2.0.6</version> </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>3.2.2</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> </dependencies> <build> <plugins> diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ContextParentType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ContextParentType.java new file mode 100644 index 0000000..b8b6e9d --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ContextParentType.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.enums; + +import lombok.Getter; +import lombok.Setter; + +@Getter +public enum ContextParentType { + INTENT(0, "intent"), + EXPECTATION(1, "expectation"), + EXPECTATION_OBJECT(2, "expectation_object"), + EXPECTATION_TARGET(3, "expectation_target"); + + private int index; + + private String desc; + + ContextParentType(int index, String desc) { + this.index = index; + this.desc = desc; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ContextType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ContextType.java new file mode 100644 index 0000000..6c25125 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ContextType.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.enums; + +import lombok.Getter; +import lombok.Setter; + +@Getter +public enum ContextType { + CONTEXTTYPE1(0, "contextType1"), + CONTEXTTYPE2(1, "contextType2"); + + private int index; + + private String desc; + + ContextType(int index, String desc) { + this.index = index; + this.desc = desc; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/DetectionGoalType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/DetectionGoalType.java new file mode 100644 index 0000000..abe3ef0 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/DetectionGoalType.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.enums; + +import lombok.Getter; + +@Getter +public enum DetectionGoalType { + ADD(0, "add"), + UPDATE(1, "update"), + DELETE(2, "delete"); + + private int index; + + private String desc; + + DetectionGoalType(int index, String desc) { + this.index = index; + this.desc = desc; + } + +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ExpectationType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ExpectationType.java new file mode 100644 index 0000000..fbddde2 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ExpectationType.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.enums; + +import lombok.Getter; +import lombok.Setter; + +@Getter +public enum ExpectationType { + EXPECTATION1(0, "expectationType1"), + EXPECTATION2(1, "expectationType2"); + + private int index; + + private String desc; + + ExpectationType(int index, String desc) { + this.index = index; + this.desc = desc; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/FulfilmentStatus.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/FulfilmentStatus.java new file mode 100644 index 0000000..7038022 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/FulfilmentStatus.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.enums; + +import lombok.Getter; +import lombok.Setter; + +@Getter +public enum FulfilmentStatus { + FULFILLED(0, "fulfilled"), + NOT_FULFILLED(1, "not_fulfilled"); + + private int index; + + private String desc; + + FulfilmentStatus(int index, String desc) { + this.index = index; + this.desc = desc; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentFunctionType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentFunctionType.java index 25cb1e5..d709fa0 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentFunctionType.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentFunctionType.java @@ -1,19 +1,17 @@ /* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. * - * * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * * - * * 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. + * 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 org.onap.usecaseui.intentanalysis.bean.enums; diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/NotFulfilledState.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/NotFulfilledState.java new file mode 100644 index 0000000..efa3581 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/NotFulfilledState.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.enums; + +import lombok.Getter; +import lombok.Setter; + +@Getter +public enum NotFulfilledState { + ACKNOWLEDGED(0, "acknowledge"), + COMPLIANT(1, "compliant"), + DEGRADED(2, "degraded"), + SUSPENDED(3, "suspended"), + TERMINATED(4, "terminated"), + FULFILMENTFAILED(5, "fulfilmentfailed"); + + private int index; + + private String desc; + + NotFulfilledState(int index, String desc) { + this.index = index; + this.desc = desc; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ObjectType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ObjectType.java new file mode 100644 index 0000000..afd1a04 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ObjectType.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.enums; + +import lombok.Getter; +import lombok.Setter; + +@Getter +public enum ObjectType { + OBJECT1(0, "objectType1"), + OBJECT2(1, "objectType2"); + + private int index; + + private String desc; + + ObjectType(int index, String desc) { + this.index = index; + this.desc = desc; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Context.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Context.java new file mode 100644 index 0000000..02aa2c2 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Context.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.models; + +import lombok.Data; +import org.onap.usecaseui.intentanalysis.bean.enums.ContextType; + +@Data + +public class Context { + + private String contextId; + + private String contextName; + + private ContextType contextType; + + private String contextCondition; + +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/DetectionGoalBean.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/DetectionGoalBean.java new file mode 100644 index 0000000..6ea045b --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/DetectionGoalBean.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.models; + +import lombok.Data; +import org.onap.usecaseui.intentanalysis.bean.enums.DetectionGoalType; + +@Data +public class DetectionGoalBean { + private Intent intent; + private DetectionGoalType detectionGoalType; + + public DetectionGoalBean(Intent intent, DetectionGoalType detectionGoalType) { + this.intent = intent; + this.detectionGoalType = detectionGoalType; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Expectation.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Expectation.java new file mode 100644 index 0000000..7ebeec2 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Expectation.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.models; + + +import java.util.List; +import lombok.Data; +import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType; +import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject; +import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget; + + +@Data + +public class Expectation { + + private String expectationId; + + private String expectationName; + + private ExpectationType expectationType; + + private ExpectationObject expectationObject; + + private List<ExpectationTarget> expectationTargets; + + private List<Context> expectationContexts; + + private FulfilmentInfo expectationFulfilmentInfo; +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObject.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObject.java new file mode 100644 index 0000000..eb4d0a8 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObject.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.models; + + +import java.util.List; +import lombok.Data; +import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType; + + +@Data + +public class ExpectationObject { + + private ObjectType objectType; + + private String objectInstance; + + private List<Context> objectContexts; +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationTarget.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationTarget.java new file mode 100644 index 0000000..412813d --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationTarget.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.models; + + +import java.util.List; +import lombok.Data; + + +@Data + +public class ExpectationTarget { + + private String targetId; + + private String targetName; + + private String targetCondition; + + private List<Context> targetContexts; + + private FulfilmentInfo targetFulfilmentInfo; +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/FulfilmentInfo.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/FulfilmentInfo.java new file mode 100644 index 0000000..17ab1b8 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/FulfilmentInfo.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.models; + +import lombok.Data; +import org.onap.usecaseui.intentanalysis.bean.enums.FulfilmentStatus; +import org.onap.usecaseui.intentanalysis.bean.enums.NotFulfilledState; + +@Data + +public class FulfilmentInfo { + + private FulfilmentStatus fulfilmentStatus; + + private NotFulfilledState notFulfilledState; + + private String notFulfilledReason; + +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java new file mode 100644 index 0000000..8f649e9 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.models; + + +import java.util.List; +import lombok.Data; + + +@Data + +public class Intent { + private String intentId; + + private String intentName; + + private List<Expectation> intentExpectations; + + private List<Context> intentContexts; + + private FulfilmentInfo intentFulfilmentInfo; + +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java index 34f56b7..5ea8ef9 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java @@ -26,10 +26,10 @@ import java.util.List; public class IntentManagementFunctionRegInfo { private String id; private String description; - private List<SupportArea> supportArea; - private String supportModel; - private List<SupportInterface> supportInterfaces; + private List<SupportArea> supportArea; //ͨ¹ýintentname cll ͨ¹ýintentName + private String supportModel; // expectation expectationtarget targetCondition value + private List<SupportInterface> supportInterfaces; // private String handleName; - private IntentFunctionType intentFunctionType; + private IntentFunctionType intentFunctionType;//out or in } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/State.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/State.java new file mode 100644 index 0000000..865c805 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/State.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * 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 org.onap.usecaseui.intentanalysis.bean.models; + +import lombok.Data; + +@Data +public class State { + + private String stateId; + + private String stateName; + + private String condition; + + private Boolean isSatisfied; + +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java index 51a4ee2..43a6247 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java @@ -15,34 +15,91 @@ */ package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule; +import org.apache.commons.collections.CollectionUtils; +import org.onap.usecaseui.intentanalysis.bean.enums.DetectionGoalType; +import org.onap.usecaseui.intentanalysis.bean.models.DetectionGoalBean; import org.onap.usecaseui.intentanalysis.bean.models.Expectation; +import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget; import org.onap.usecaseui.intentanalysis.bean.models.Intent; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule; +import org.onap.usecaseui.intentanalysis.service.IntentService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + @Service public class CLLBusinessKnowledgeModule implements KnowledgeModule { + private static Logger LOGGER = LoggerFactory.getLogger(CLLBusinessKnowledgeModule.class); + + @Autowired + IntentService intentService; @Override public Intent intentCognition(Intent intent) { - intentResolution(intent); - //intentReportResolution(); + List<String> intendIdList = intentResolution(intent); getSystemStatus(); - //interactWithIntentOwner(); - determineDetectionGoal(); + determineDetectionGoal(intent, intendIdList); return null; } - //find similar intents in DB - void intentResolution(Intent intent) { + /** + * find similar intents in DB + * + * @param intent + */ + public List<String> intentResolution(Intent intent) { + //dc contain original intent + String intentName = intent.getIntentName(); + List<Intent> intentList = intentService.getIntentList(); + List<Intent> sameNameIntentList = intentList.stream().filter(x -> x.getIntentName() + .contains(intentName)).collect(Collectors.toList()); + List<String> intentIdList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(sameNameIntentList)) { + List<Expectation> expectationList = intent.getIntentExpectations(); + for (Intent dbIntent : sameNameIntentList) { + String intentId = dbIntent.getIntentId(); + int count = 0; + for (Expectation expectation : expectationList) {//original expectations + //Determine if there is the same ObjectType + List<Expectation> sameObjTypeList = dbIntent.getIntentExpectations().stream() + .filter(x -> x.getExpectationObject().getObjectType().equals(expectation.getExpectationObject().getObjectType())) + .collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(sameObjTypeList)) { + //Determine the targetName of the Expectation which hava same ObjectType + List<String> targetNameList = expectation.getExpectationTargets() + .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); + for (Expectation dbExpectation : sameObjTypeList) { + List<String> dbTargetNameList = dbExpectation.getExpectationTargets() + .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); + //todo name compare need ai + if (dbTargetNameList.containsAll(targetNameList)) { + count++; + break; + } + } + } + if (count == expectationList.size()) { + intentIdList.add(intentId); + break; + } + } + } + } + return intentIdList; } void intentReportResolution() { } - - //query the implementation of intent requirements in the system + /** + * query the implementation of intent requirements in the system + */ void getSystemStatus() { } @@ -50,9 +107,16 @@ public class CLLBusinessKnowledgeModule implements KnowledgeModule { void interactWithIntentOwner() { } - - //Determine add, delete, modify according to theobject,target and context of the expectation - void determineDetectionGoal() { + /** + * Determine add, delete, modify according to theobject,target and context of the expectation + */ + DetectionGoalBean determineDetectionGoal(Intent intent, List<String> intentIdList) { + int size = intentIdList.size(); + if (size == 0) { + return new DetectionGoalBean(intent, DetectionGoalType.ADD); + } else { + return new DetectionGoalBean(intent, DetectionGoalType.UPDATE); + } } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java index 6144e97..ab2419f 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java @@ -32,7 +32,7 @@ public class IntentHandleService { * @param intent */ public void handleOriginalIntent(Intent intent){ - IntentManagementFunction intentOwner = selectIntentManagementFunction(intent); + IntentManagementFunction intentOwner = getOtigalIMF(intent); handleIntent(intent,intentOwner); } @@ -55,4 +55,9 @@ public class IntentHandleService { //This is used to get he IntentManagementFunction for a subIntent decomposition. return null; } + + public IntentManagementFunction getOtigalIMF(Intent intent){ + //select IntentManagementFunction based on intent name + return null; + } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java index 44e2a01..867f315 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java @@ -34,4 +34,6 @@ public interface IntentMapper { List<Intent> selectIntents(); int deleteIntentById(String intentId); + + List<Intent> getIntentByName(String name); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java index c177caa..9986351 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java @@ -31,4 +31,6 @@ public interface IntentService { Intent updateIntent(Intent intent); void deleteIntentById(String intentId); + + List<Intent> getIntentByName(String name); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java index f4e49d8..7f491c9 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java @@ -20,6 +20,7 @@ package org.onap.usecaseui.intentanalysis.service.impl; import java.util.ArrayList; import java.util.List; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -125,4 +126,19 @@ public class IntentServiceImpl implements IntentService { expectationService.deleteIntentExpectationsByIntentId(intentId); log.debug("Intent has been deleted successfully."); } + + @Override + public List<Intent> getIntentByName(String name) { + List<Intent> intentList = intentMapper.getIntentByName(name); + if (CollectionUtils.isNotEmpty(intentList)) { + for (Intent intent:intentList) { + intent.setIntentExpectations(expectationService.getIntentExpectationsByIntentId(intent.getIntentId())); + } + return intentList; + } else { + String msg = String.format("Intent name contain %s doesn't exist in database.", name); + log.error(msg); + throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY); + } + } } diff --git a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml index 5e2847b..9d6029f 100644 --- a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml +++ b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml @@ -31,4 +31,9 @@ where intent_id = #{intentId} </delete> + <select id="getIntentByName" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent"> + select intent_id intentId, intent_name intentName from intent + where intent_name like "%"#{intentName}"%" + </select> + </mapper>
\ No newline at end of file |