mirror of
https://github.com/OpenSPG/openspg.git
synced 2025-08-03 14:32:09 +00:00
bugfix
This commit is contained in:
parent
38be46a698
commit
1a27ff937d
@ -9,7 +9,7 @@ import com.antgroup.openspg.builder.model.pipeline.config.RelationMappingNodeCon
|
|||||||
import com.antgroup.openspg.builder.model.record.BaseRecord;
|
import com.antgroup.openspg.builder.model.record.BaseRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.BuilderRecord;
|
import com.antgroup.openspg.builder.model.record.BuilderRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.RelationRecord;
|
import com.antgroup.openspg.builder.model.record.RelationRecord;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.EdgeRecordConvertor;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.EdgeRecordConvertor;
|
||||||
import com.antgroup.openspg.common.util.StringUtils;
|
import com.antgroup.openspg.common.util.StringUtils;
|
||||||
import com.antgroup.openspg.core.schema.model.identifier.RelationIdentifier;
|
import com.antgroup.openspg.core.schema.model.identifier.RelationIdentifier;
|
||||||
import com.antgroup.openspg.core.schema.model.predicate.Relation;
|
import com.antgroup.openspg.core.schema.model.predicate.Relation;
|
||||||
|
@ -22,7 +22,7 @@ import com.antgroup.openspg.builder.model.pipeline.config.SPGTypeMappingNodeConf
|
|||||||
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
|
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.BaseRecord;
|
import com.antgroup.openspg.builder.model.record.BaseRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.BuilderRecord;
|
import com.antgroup.openspg.builder.model.record.BuilderRecord;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.VertexRecordConvertor;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.VertexRecordConvertor;
|
||||||
import com.antgroup.openspg.common.util.StringUtils;
|
import com.antgroup.openspg.common.util.StringUtils;
|
||||||
import com.antgroup.openspg.core.schema.model.identifier.SPGTypeIdentifier;
|
import com.antgroup.openspg.core.schema.model.identifier.SPGTypeIdentifier;
|
||||||
import com.antgroup.openspg.core.schema.model.type.BaseSPGType;
|
import com.antgroup.openspg.core.schema.model.type.BaseSPGType;
|
||||||
|
@ -24,8 +24,8 @@ import com.antgroup.openspg.builder.model.record.BaseSPGRecord;
|
|||||||
import com.antgroup.openspg.builder.model.record.RelationRecord;
|
import com.antgroup.openspg.builder.model.record.RelationRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
|
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.property.SPGPropertyValue;
|
import com.antgroup.openspg.builder.model.record.property.SPGPropertyValue;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.EdgeRecordConvertor;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.EdgeRecordConvertor;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.VertexRecordConvertor;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.VertexRecordConvertor;
|
||||||
import com.antgroup.openspg.common.util.CollectionsUtils;
|
import com.antgroup.openspg.common.util.CollectionsUtils;
|
||||||
import com.antgroup.openspg.core.schema.model.identifier.RelationIdentifier;
|
import com.antgroup.openspg.core.schema.model.identifier.RelationIdentifier;
|
||||||
import com.antgroup.openspg.core.schema.model.identifier.SPGTypeIdentifier;
|
import com.antgroup.openspg.core.schema.model.identifier.SPGTypeIdentifier;
|
||||||
|
@ -18,8 +18,8 @@ import com.antgroup.openspg.builder.model.record.RecordAlterOperationEnum;
|
|||||||
import com.antgroup.openspg.builder.model.record.SPGRecordAlterItem;
|
import com.antgroup.openspg.builder.model.record.SPGRecordAlterItem;
|
||||||
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
|
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.BaseLPGGraphStoreClient;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.BaseLPGGraphStoreClient;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.EdgeRecordConvertor;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.EdgeRecordConvertor;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.VertexRecordConvertor;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.VertexRecordConvertor;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.OneHopLPGRecordQuery;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.OneHopLPGRecordQuery;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.Direction;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.Direction;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGRecordAlterItem;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGRecordAlterItem;
|
||||||
|
@ -15,7 +15,7 @@ package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.
|
|||||||
|
|
||||||
import com.antgroup.openspg.builder.model.record.RelationRecord;
|
import com.antgroup.openspg.builder.model.record.RelationRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.SPGRecordAlterItem;
|
import com.antgroup.openspg.builder.model.record.SPGRecordAlterItem;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.EdgeRecordConvertor;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.EdgeRecordConvertor;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGRecordAlterItem;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGRecordAlterItem;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,7 +15,7 @@ package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.
|
|||||||
|
|
||||||
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
|
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.SPGRecordAlterItem;
|
import com.antgroup.openspg.builder.model.record.SPGRecordAlterItem;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.VertexRecordConvertor;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.VertexRecordConvertor;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGRecordAlterItem;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGRecordAlterItem;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* or implied.
|
* or implied.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor;
|
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util;
|
||||||
|
|
||||||
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
|
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.RelationRecord;
|
import com.antgroup.openspg.builder.model.record.RelationRecord;
|
||||||
@ -19,7 +19,6 @@ import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
|
|||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.EdgeRecord;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.EdgeRecord;
|
||||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.schema.EdgeTypeName;
|
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.schema.EdgeTypeName;
|
||||||
import com.antgroup.openspg.core.schema.model.predicate.Relation;
|
import com.antgroup.openspg.core.schema.model.predicate.Relation;
|
||||||
import com.antgroup.openspg.core.schema.model.type.SPGTypeRef;
|
|
||||||
import com.antgroup.openspg.server.common.model.exception.GraphStoreException;
|
import com.antgroup.openspg.server.common.model.exception.GraphStoreException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -29,6 +28,7 @@ import java.util.stream.Collectors;
|
|||||||
/** Convertor for {@link EdgeRecord} and {@link RelationRecord}. */
|
/** Convertor for {@link EdgeRecord} and {@link RelationRecord}. */
|
||||||
public class EdgeRecordConvertor {
|
public class EdgeRecordConvertor {
|
||||||
|
|
||||||
|
/** Convert the SPG record to an LPG record. */
|
||||||
public static EdgeRecord toEdgeRecord(RelationRecord relationRecord) {
|
public static EdgeRecord toEdgeRecord(RelationRecord relationRecord) {
|
||||||
Relation relationType = relationRecord.getRelationType();
|
Relation relationType = relationRecord.getRelationType();
|
||||||
return new EdgeRecord(
|
return new EdgeRecord(
|
||||||
@ -42,19 +42,9 @@ public class EdgeRecordConvertor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert {@link SPGPropertyRecord} in {@link BaseAdvancedRecord} into edge records.
|
* For an advanced SPG record, when one of its property types is also an advanced type, an edge
|
||||||
* Specifically, {@link BaseAdvancedRecord#getName()}, {@link BaseAdvancedRecord#getId()}, {@link
|
* will be created between the current instance and the instance corresponding to that property
|
||||||
* SPGPropertyRecord#getName()}, {@link SPGTypeRef#getName()} from {@link SPGPropertyRecord}, and
|
* value.
|
||||||
* be assigned to start vertex's type name, start vertex's ID, edge label, and end vertex's type
|
|
||||||
* name of {@link EdgeRecord}s. And end vertex's IDs of {@link EdgeRecord}s will be split from
|
|
||||||
* {@link SPGPropertyRecord#getValue()}
|
|
||||||
*
|
|
||||||
* @param advancedRecord advanced record, such as {@link
|
|
||||||
* com.antgroup.openspg.builder.model.record.EventRecord EventRecord}, {@link
|
|
||||||
* com.antgroup.openspg.builder.model.record.EntityRecord EntityRecord} and {@link
|
|
||||||
* com.antgroup.openspg.builder.model.record.ConceptRecord ConceptRecord}.
|
|
||||||
* @param spgPropertyRecord record of <tt>SPG</tt> property.
|
|
||||||
* @return a list of {@link EdgeRecord}s
|
|
||||||
*/
|
*/
|
||||||
public static List<EdgeRecord> toEdgeRecords(
|
public static List<EdgeRecord> toEdgeRecords(
|
||||||
BaseAdvancedRecord advancedRecord, SPGPropertyRecord spgPropertyRecord) {
|
BaseAdvancedRecord advancedRecord, SPGPropertyRecord spgPropertyRecord) {
|
||||||
@ -77,6 +67,10 @@ public class EdgeRecordConvertor {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the LPG record to an SPG record, mainly used in the mapping or reasoning process of
|
||||||
|
* knowledge builder.
|
||||||
|
*/
|
||||||
public static RelationRecord toRelationRecord(
|
public static RelationRecord toRelationRecord(
|
||||||
Relation relationType, String srcId, String dstId, Map<String, String> properties) {
|
Relation relationType, String srcId, String dstId, Map<String, String> properties) {
|
||||||
return new RelationRecord(
|
return new RelationRecord(
|
@ -11,7 +11,7 @@
|
|||||||
* or implied.
|
* or implied.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor;
|
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util;
|
||||||
|
|
||||||
import com.antgroup.openspg.builder.model.record.property.BasePropertyRecord;
|
import com.antgroup.openspg.builder.model.record.property.BasePropertyRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
|
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
|
||||||
@ -29,6 +29,7 @@ import org.apache.commons.collections4.MapUtils;
|
|||||||
/** Convertor for {@link LPGPropertyRecord} and {@link SPGPropertyRecord}. */
|
/** Convertor for {@link LPGPropertyRecord} and {@link SPGPropertyRecord}. */
|
||||||
public class PropertyRecordConvertor {
|
public class PropertyRecordConvertor {
|
||||||
|
|
||||||
|
/** Convert the SPG record to an LPG record. */
|
||||||
public static List<LPGPropertyRecord> toLPGProperties(
|
public static List<LPGPropertyRecord> toLPGProperties(
|
||||||
List<? extends BasePropertyRecord> propertyRecords) {
|
List<? extends BasePropertyRecord> propertyRecords) {
|
||||||
List<LPGPropertyRecord> resultProperties = new ArrayList<>(propertyRecords.size());
|
List<LPGPropertyRecord> resultProperties = new ArrayList<>(propertyRecords.size());
|
||||||
@ -45,6 +46,7 @@ public class PropertyRecordConvertor {
|
|||||||
return resultProperties;
|
return resultProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Convert the LPG record to an SPG record. */
|
||||||
public static List<SPGPropertyRecord> toSPGProperties(
|
public static List<SPGPropertyRecord> toSPGProperties(
|
||||||
Map<String, String> properties, BaseSPGType spgType) {
|
Map<String, String> properties, BaseSPGType spgType) {
|
||||||
if (MapUtils.isEmpty(properties)) {
|
if (MapUtils.isEmpty(properties)) {
|
||||||
@ -64,6 +66,7 @@ public class PropertyRecordConvertor {
|
|||||||
return spgPropertyRecords;
|
return spgPropertyRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Convert the LPG record to an SPG record. */
|
||||||
public static List<SPGSubPropertyRecord> toSPGProperties(
|
public static List<SPGSubPropertyRecord> toSPGProperties(
|
||||||
Map<String, String> properties, Property spgProperty) {
|
Map<String, String> properties, Property spgProperty) {
|
||||||
if (!spgProperty.hasSubProperty()) {
|
if (!spgProperty.hasSubProperty()) {
|
@ -11,7 +11,7 @@
|
|||||||
* or implied.
|
* or implied.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor;
|
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util;
|
||||||
|
|
||||||
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
|
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
|
||||||
import com.antgroup.openspg.builder.model.record.ConceptRecord;
|
import com.antgroup.openspg.builder.model.record.ConceptRecord;
|
||||||
@ -39,6 +39,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class VertexRecordConvertor {
|
public class VertexRecordConvertor {
|
||||||
|
|
||||||
|
/** Convert the SPG record to an LPG record. */
|
||||||
public static VertexRecord toVertexRecord(BaseAdvancedRecord advancedRecord) {
|
public static VertexRecord toVertexRecord(BaseAdvancedRecord advancedRecord) {
|
||||||
return new VertexRecord(
|
return new VertexRecord(
|
||||||
advancedRecord.getId(),
|
advancedRecord.getId(),
|
||||||
@ -46,6 +47,10 @@ public class VertexRecordConvertor {
|
|||||||
PropertyRecordConvertor.toLPGProperties(advancedRecord.getProperties()));
|
PropertyRecordConvertor.toLPGProperties(advancedRecord.getProperties()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the SPG property record to an LPG record, which is currently used only for standard
|
||||||
|
* types, as a standard type will automatically generate an LPG record based on the property.
|
||||||
|
*/
|
||||||
public static List<VertexRecord> toVertexRecords(SPGPropertyRecord propertyRecord) {
|
public static List<VertexRecord> toVertexRecords(SPGPropertyRecord propertyRecord) {
|
||||||
if (propertyRecord.isBasicType()) {
|
if (propertyRecord.isBasicType()) {
|
||||||
throw GraphStoreException.unexpectedSPGPropertyRecordType(propertyRecord);
|
throw GraphStoreException.unexpectedSPGPropertyRecordType(propertyRecord);
|
||||||
@ -57,6 +62,10 @@ public class VertexRecordConvertor {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the LPG record to an SPG record, mainly used in the mapping or reasoning process of
|
||||||
|
* knowledge builder.
|
||||||
|
*/
|
||||||
public static BaseAdvancedRecord toAdvancedRecord(
|
public static BaseAdvancedRecord toAdvancedRecord(
|
||||||
BaseSPGType baseSpgType, String bizId, Map<String, String> properties) {
|
BaseSPGType baseSpgType, String bizId, Map<String, String> properties) {
|
||||||
BaseAdvancedRecord advancedRecord = null;
|
BaseAdvancedRecord advancedRecord = null;
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util
|
||||||
|
|
||||||
|
import spock.lang.Specification
|
||||||
|
|
||||||
|
class VertexRecordConvertorTest extends Specification {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user