1

对于jQAssistant插件,我创建了一个关系描述符,如http://buschmais.github.io/extended-objects/doc/0.8.0/neo4j/#_unidirectional_relations中所述

它看起来像这样:

@Relation
public interface PlantUmlSequenceDiagramMessageDescriptor 
    extends Descriptor {

    @Relation.Outgoing
    PlantUmlParticipantDescriptor getSourceParticipant();

    @Relation.Incoming
    PlantUmlParticipantDescriptor getTargetParticipant();

    void setMessage(String messageText);
    String getMessage();

    void setMessageNumber(String messageNumber);
    String getMessageNumber();
}

但是在使用的时候:

final PlantUmlSequenceDiagramMessageDescriptor messageDescriptor = 
    store.create(p1, PlantUmlSequenceDiagramMessageDescriptor.class, p2);

我得到一个例外:

2017-12-21 19:37:16.591 [main] ERROR ScannerImpl - Unexpected problem encountered while scanning: item='plantuml\src\test\plantuml\sequence.puml', path='/sequence.puml', scope='NONE', pipeline='[com.buschmais.jqassistant.plugin.common.impl.scanner.FileResourceSc
annerPlugin@65d93024, de.kontext_e.jqassistant.plugin.plantuml.scanner.PlantUmlFileScannerPlugin@72dcb917]'. Please report this error including the full stacktrace (continueOnError=true).
com.buschmais.xo.api.XOException: Cannot resolve property in type 'de.kontext_e.jqassistant.plugin.plantuml.store.descriptor.PlantUmlParticipantDescriptor' for relation type 'de.kontext_e.jqassistant.plugin.plantuml.store.descriptor.PlantUmlSequenceDiagramMessag
eDescriptor'.
    at com.buschmais.xo.impl.metadata.RelationTypeMetadataResolver.getRelationPropertyMethodMetadata(RelationTypeMetadataResolver.java:131)
    at com.buschmais.xo.impl.metadata.MetadataProviderImpl.getPropertyMetadata(MetadataProviderImpl.java:146)
    at com.buschmais.xo.impl.XOManagerImpl.createByExample(XOManagerImpl.java:288)
    at com.buschmais.xo.impl.XOManagerImpl.create(XOManagerImpl.java:272)
    at com.buschmais.jqassistant.core.store.impl.AbstractGraphStore.create(AbstractGraphStore.java:83)
    at de.kontext_e.jqassistant.plugin.plantuml.scanner.PumlLineParser.addEvent(PumlLineParser.java:286)

用属性创建关系的正确方法是什么?我已经尝试为传出和传入关系添加设置器,但无济于事。

4

1 回答 1

1

您创建关系的方式是正确的。但是,异常消息表明您尚未将关系映射到PlantUmlParticipantDescriptor. 在您的情况下,PlantUmlParticipantDescriptor界面应如下所示:

@Label
public interface PlantUmlParticipantDescriptor {
    @Relation.Outgoing
    Set<PlantUmlSequenceDiagramMessageDescriptor> getSource();

    @Relation.Incoming
    Set<PlantUmlSequenceDiagramMessageDescriptor> getTarget();
}

@Relation
public interface PlantUmlSequenceDiagramMessageDescriptor {

    @Relation.Outgoing
    PlantUmlParticipantDescriptor getSourceParticipant();

    @Relation.Incoming
    PlantUmlParticipantDescriptor getTargetParticipant();

    void setMessage(String messageText);
    String getMessage();

    void setMessageNumber(String messageNumber);
    String getMessageNumber();
}

然后您可以按预期设置属性:

PlantUmlParticipantDescriptor  t1 = this.xoManager.create(PlantUmlParticipantDescriptor.class);
PlantUmlParticipantDescriptor  t2 = this.xoManager.create(PlantUmlParticipantDescriptor .class);
PlantUmlSequenceDiagramMessageDescriptor d = this.xoManager.create(t1, PlantUmlSequenceDiagramMessageDescriptor.class, t2);
d.setMessage("Test Message");
于 2017-12-22T07:43:17.567 回答