如何在类中获得PATH注释



我有下一个我解决不了的问题。

我不知道如何在不同的类中访问下一个注释(IdentificationCluster的@Path注释)。问题是,我遵循使用getAnnotation()方法获取注释的典型方法,但不可能获得。

package org.example.n2composition;
import com.nedap.archie.rm.archetyped.FeederAudit;
import com.nedap.archie.rm.generic.Participation;
import com.nedap.archie.rm.generic.PartyIdentified;
import com.nedap.archie.rm.generic.PartyProxy;
import java.lang.String;
import java.time.temporal.TemporalAccessor;
import java.util.List;
import javax.annotation.processing.Generated;
import org.ehrbase.client.annotations.Archetype;
import org.ehrbase.client.annotations.Entity;
import org.ehrbase.client.annotations.Id;
import org.ehrbase.client.annotations.Path;
import org.ehrbase.client.annotations.Template;
import org.ehrbase.client.classgenerator.interfaces.CompositionEntity;
import org.ehrbase.client.classgenerator.shareddefinition.Category;
import org.ehrbase.client.classgenerator.shareddefinition.Language;
import org.ehrbase.client.classgenerator.shareddefinition.Setting;
import org.ehrbase.client.classgenerator.shareddefinition.Territory;
import org.ehrbase.client.openehrclient.VersionUid;
import org.example.n2composition.definition.CodedTextDefiningCode;
import org.example.n2composition.definition.IdentificationCluster;
import org.example.n2composition.definition.PatientroleCluster;
import org.example.n2composition.definition.ProblemDiagnosisEvaluation;
@Entity
@Archetype("openEHR-EHR-COMPOSITION.information.v0")
@Generated(
value = "org.ehrbase.client.classgenerator.ClassGenerator",
date = "2023-03-24T11:50:15.994180+01:00",
comments = "https://github.com/ehrbase/openEHR_SDK Version: 1.26.0-SNAPSHOT"
)
@Template("2")
public class N2Composition implements CompositionEntity {
/**
* Path: 2/Coded text
*/
@Path("/category[at0001]|defining_code")
private CodedTextDefiningCode codedTextDefiningCode;
/**
* Path: 2/Event Context/CLUSTER/identification
* Description: identification
*/
@Path("/context[at0002]/other_context[at0018]/items[at0019]/items[openEHR-EHR-CLUSTER.identification.v0]")
private IdentificationCluster identification;

当我尝试调用注释时,会出现下一个错误。

package org.example;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.nedap.archie.rm.datavalues.DvCodedText;
import org.ehrbase.client.annotations.Template;
import org.example.n2composition.N2Composition;
import org.example.n2composition.definition.IdentificationCluster;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(String[] args) throws NoSuchFieldException {
//Lectura del fichero para obtener los path y los valores
ReadingFile r = new ReadingFile();
r.resultado();
String s1 = "C:\Users\omarah\Documents\ETL\MAPEOS\MAPEO1_1.txt";
String s2 = "C:\Users\omarah\Documents\ETL\MAPEOS\ATRIBUTOSYVALORES-DIAGNÓSTICO2.txt";
r.reading(s1,s2);
/*System.out.println(r.getResult1());
System.out.println(r.getResult1().size());
System.out.println(r.getResult2());
System.out.println(r.getResult2().size());
System.out.println(r.getElements());
System.out.println(r.getElements().size());*/
List<String> list1 = r.getResult1();
List<String> list2 = r.getResult2();
//Finalización de la lectura del path
//Creación de la composición y empezar a darle valores
N2Composition n2 = new N2Composition(); //crear nueva COMPOSITION
IdentificationCluster i = new IdentificationCluster();
DvCodedText dv = new DvCodedText();
dv.setValue("hola");
i.setDvCodedText(dv);
Field f = N2Composition.class.getDeclaredField("identification");
String p = f.getAnnotation(Path.class).value();
n2.setIdentification(i);
//String p = s.g
//System.out.println(p);



//n2.setIdentification((i.setDvCodedText(dv.setValue(list2[])));
}

}

输入图片描述

有人知道怎么解吗?

看起来您的导入是不正确的。

在N2Composition类中使用importorg.ehrbase.client.annotations.Path;

,然后在Main类中(也在错误消息中)java.nio.file.Path

相关内容

  • 没有找到相关文章