diff --git a/builder/model/src/test/groovy/com/antgroup/openspg/builder/model/record/property/SPGPropertyValueTest.groovy b/builder/model/src/test/groovy/com/antgroup/openspg/builder/model/record/property/SPGPropertyValueTest.groovy deleted file mode 100644 index c6c0fdc5d..000000000 --- a/builder/model/src/test/groovy/com/antgroup/openspg/builder/model/record/property/SPGPropertyValueTest.groovy +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2023 OpenSPG Authors - * - * 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. - */ - -package com.antgroup.openspg.builder.model.record.property - -import spock.lang.Specification - -class SPGPropertyValueTest extends Specification { - - def "testGetStdValue"() { - given: - def value = new SPGPropertyValue("bd8cc63024c7a1d4adb3d08f0f4d4827,1ef0e106653b871d429cfab0cd5ea70a") - value.setStds(["bd8cc63024c7a1d4adb3d08f0f4d4827", "1ef0e106653b871d429cfab0cd5ea70a"]) - - expect: - value.getStdValue() == 'bd8cc63024c7a1d4adb3d08f0f4d4827,1ef0e106653b871d429cfab0cd5ea70a' - } - - def "testMerge"() { - expect: - def otherValue = new SPGPropertyValue("bd8cc63024c7a1d4adb3d08f0f4d4827") - value.merge(otherValue) - value.getRaw() == expectRaw - - where: - value || expectRaw - new SPGPropertyValue(null) || "bd8cc63024c7a1d4adb3d08f0f4d4827" - new SPGPropertyValue("1ef0e106653b871d429cfab0cd5ea70a") || "1ef0e106653b871d429cfab0cd5ea70a,bd8cc63024c7a1d4adb3d08f0f4d4827" - } -} diff --git a/cloudext/interface/graph-store/src/test/groovy/com/antgroup/openspg/cloudext/interfaces/graphstore/RiskMiningLPGRecord.groovy b/cloudext/interface/graph-store/src/test/groovy/com/antgroup/openspg/cloudext/interfaces/graphstore/RiskMiningLPGRecord.groovy deleted file mode 100644 index 31e2e1a3e..000000000 --- a/cloudext/interface/graph-store/src/test/groovy/com/antgroup/openspg/cloudext/interfaces/graphstore/RiskMiningLPGRecord.groovy +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 OpenSPG Authors - * - * 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. - */ - -package com.antgroup.openspg.cloudext.interfaces.graphstore - -import com.antgroup.openspg.builder.test.RiskMiningRecord -import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGPropertyRecord -import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord -import spock.lang.Specification - -class RiskMiningLPGRecord extends Specification { - - public final static VertexRecord PERSON_RECORD1 = new VertexRecord( - RiskMiningRecord.PERSON_RECORD1.id, - RiskMiningRecord.PERSON_RECORD1.getName(), - [ - new LPGPropertyRecord("name", "裘**"), - new LPGPropertyRecord("age", 58L), - new LPGPropertyRecord("hasPhone", "154****7458"), - ] - ); -} diff --git a/cloudext/interface/graph-store/src/test/groovy/com/antgroup/openspg/cloudext/interfaces/graphstore/adapter/util/VertexRecordConvertorTest.groovy b/cloudext/interface/graph-store/src/test/groovy/com/antgroup/openspg/cloudext/interfaces/graphstore/adapter/util/VertexRecordConvertorTest.groovy deleted file mode 100644 index 638555a47..000000000 --- a/cloudext/interface/graph-store/src/test/groovy/com/antgroup/openspg/cloudext/interfaces/graphstore/adapter/util/VertexRecordConvertorTest.groovy +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2023 OpenSPG Authors - * - * 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. - */ - -package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util - -import com.antgroup.openspg.builder.test.RiskMiningRecord -import com.antgroup.openspg.cloudext.interfaces.graphstore.RiskMiningLPGRecord -import spock.lang.Specification - -class VertexRecordConvertorTest extends Specification { - - def testToVertexRecord() { - expect: - outputRecord == VertexRecordConvertor.toVertexRecord(inputRecord) - - where: - inputRecord || outputRecord - RiskMiningRecord.PERSON_RECORD1_NORMALIZED || RiskMiningLPGRecord.PERSON_RECORD1 - } -} diff --git a/reasoner/runner/runner-common/src/main/java/com/antgroup/openspg/reasoner/rdg/common/LinkEdgeImpl.java b/reasoner/runner/runner-common/src/main/java/com/antgroup/openspg/reasoner/rdg/common/LinkEdgeImpl.java index 2d0838278..1c4b088c0 100644 --- a/reasoner/runner/runner-common/src/main/java/com/antgroup/openspg/reasoner/rdg/common/LinkEdgeImpl.java +++ b/reasoner/runner/runner-common/src/main/java/com/antgroup/openspg/reasoner/rdg/common/LinkEdgeImpl.java @@ -92,6 +92,21 @@ public LinkEdgeImpl( this.initContext = RunnerUtil.getKgGraphInitContext(kgGraphSchema); } + private boolean isTargetVertexTypeEmpty(List targetVertexTypes) { + if (null == targetVertexTypes || targetVertexTypes.isEmpty()) { + return true; + } + for (String type : targetVertexTypes) { + if ("RdfProperty".equals(type)) { + continue; + } + if (StringUtils.isNotEmpty(type)) { + return false; + } + } + return true; + } + public List> link(KgGraph kgGraph) { Iterator> it = kgGraph.getPath(staticParameters, null); List> mergeList = new ArrayList<>(); @@ -143,9 +158,12 @@ public List> link(KgGraph kgGraph) { String targetAlias = targetVertexMeta.alias(); List targetVertexTypes = new ArrayList<>(JavaConversions.setAsJavaSet(targetVertexMeta.typeNames())); - if (targetVertexTypes.size() == 0) { - throw new RuntimeException( - "Linked edge target vertex type must contains at least one type"); + if (isTargetVertexTypeEmpty(targetVertexTypes)) { + targetVertexTypes = Lists.newArrayList(linkedUdtfResult.getVertexType()); + if (isTargetVertexTypeEmpty(targetVertexTypes)) { + throw new RuntimeException( + "Linked edge target vertex type must contains at least one type"); + } } for (String targetVertexType : targetVertexTypes) { IVertexId targetId = new VertexId(targetIdStr, targetVertexType); diff --git a/reasoner/udf/src/main/java/com/antgroup/openspg/reasoner/udf/model/LinkedUdtfResult.java b/reasoner/udf/src/main/java/com/antgroup/openspg/reasoner/udf/model/LinkedUdtfResult.java index 11ea52597..944a15160 100644 --- a/reasoner/udf/src/main/java/com/antgroup/openspg/reasoner/udf/model/LinkedUdtfResult.java +++ b/reasoner/udf/src/main/java/com/antgroup/openspg/reasoner/udf/model/LinkedUdtfResult.java @@ -30,4 +30,7 @@ public class LinkedUdtfResult { /** edge type */ private String edgeType = null; + + /** vertex type */ + private String vertexType = null; }