Commit 09f537cc authored by Ryan Berkheimer's avatar Ryan Berkheimer

completed adding Rejection methods to C endpoint API

parent 97e0368a
Pipeline #5749 failed with stages
in 0 seconds
......@@ -24,6 +24,7 @@ MessageApiEndpoint::MessageApiEndpoint(JNIEnv *env, jobject jendpoint, jobject j
this->loadPacketMethodIds();
this->loadProtocolRecordMethodIds();
this->loadRecordMethodIds();
this->loadRejectionMethodIds();
this->loadFieldMethodIds();
this->loadConditionMethodIds();
this->loadValueTypeMethodIds();
......@@ -122,6 +123,16 @@ void MessageApiEndpoint::loadRecordMethodIds()
this->jvm->DeleteLocalRef(recordClass);
}
void MessageApiEndpoint::loadRejectionMethodIds()
{
jclass rejectionClass = this->getNamedClass("gov/noaa/messageapi/interfaces/IRejection");
this->getRejectionCopyMethodId = this->getMethod(rejectionClass, "getCopy", this->getRejectionMethodSignature("getCopy"), false);
this->getRejectionReasonsMethodId = this->getMethod(rejectionClass, "getReasons", this->getRejectionMethodSignature("getReasons"), false);
this->getRejectionRecordMethodId = this->getMethod(rejectionClass, "getRecord", this->getRejectionMethodSignature("getRecord"), false);
this->addRejectionReasonMethodId = this->getMethod(rejectionClass, "addReason", this->getRejectionMethodSignature("addReason"), false);
this->jvm->DeleteLocalRef(rejectionClass);
}
void MessageApiEndpoint::loadFieldMethodIds()
{
jclass fieldClass = this->getNamedClass("gov/noaa/messageapi/interfaces/IField");
......@@ -399,6 +410,28 @@ const char *MessageApiEndpoint::getRecordMethodSignature(const char *methodName)
return NULL;
}
const char *MessageApiEndpoint::getRejectionMethodSignature(const char *methodName)
{
if (strcmp(methodName, "getCopy") == 0)
{
return "()Lgov/noaa/messageapi/interfaces/IRejection;";
}
else if (strcmp(methodName, "getReasons") == 0)
{
return "()Ljava/util/List;";
}
else if (strcmp(methodName, "getRecord") == 0)
{
return "()Lgov/noaa/messageapi/interfaces/IRecord;";
}
else if (strcmp(methodName, "addReason") == 0)
{
return "(Ljava/lang/String;)V";
}
return NULL;
}
const char *MessageApiEndpoint::getFieldMethodSignature(const char *methodName)
{
if (strcmp(methodName, "getId") == 0)
......@@ -1241,6 +1274,35 @@ void MessageApiEndpoint::addRejectionEntry(struct rejection_list *rejection_list
rejection_list->count += 1;
}
struct rejection *MessageApiEndpoint::getRejectionCopy(struct rejection *rejection)
{
jobject jRejectionCopy = this->jvm->CallObjectMethod(rejection->jrejection, this->getRejectionCopyMethodId);
struct rejection *rejectionCopy = (struct rejection *)malloc(sizeof(struct rejection) + sizeof(jRejectionCopy));
rejectionCopy->jrejection = jRejectionCopy;
return rejectionCopy;
}
struct record *MessageApiEndpoint::getRejectionRecord(struct rejection *rejection)
{
jobject jRecord = this->jvm->CallObjectMethod(rejection->jrejection, this->getRejectionRecordMethodId);
struct record *record = (struct record *)malloc(sizeof(struct record) + sizeof(jRecord));
record->jrecord = jRecord;
return record;
}
struct string_list *MessageApiEndpoint::getRejectionReasons(struct rejection *rejection)
{
jobject jReasons = this->jvm->CallObjectMethod(rejection->jrejection, this->getRejectionReasonsMethodId);
struct string_list *reasons = this->translateFromJavaStringList(jReasons);
return reasons;
}
void MessageApiEndpoint::addRejectionReason(struct rejection *rejection, const char *reason)
{
jstring jReason = this->toJavaString(reason);
this->jvm->CallVoidMethod(rejection->jrejection, this->addRejectionReasonMethodId, jReason);
}
struct val_list *MessageApiEndpoint::createList()
{
jobject jList = this->jvm->NewObject(this->jArrayListClass, this->createJArrayListMethodId);
......
......@@ -70,6 +70,10 @@ public:
/*Rejection Methods*/
struct rejection_list *createRejectionList();
void addRejectionEntry(struct rejection_list *rejection_list, struct rejection *rejection);
struct rejection *getRejectionCopy(struct rejection *rejection);
struct record *getRejectionRecord(struct rejection *rejection);
struct string_list *getRejectionReasons(struct rejection *rejection);
void addRejectionReason(struct rejection *rejection, const char *reason);
/*Field Methods*/
const char *getFieldId(struct field *field);
......@@ -206,6 +210,12 @@ private :
jmethodID getRecordHasConditionMethodId;
jmethodID getRecordConditionMethodId;
/*Rejection Methods*/
jmethodID getRejectionCopyMethodId;
jmethodID getRejectionReasonsMethodId;
jmethodID getRejectionRecordMethodId;
jmethodID addRejectionReasonMethodId;
/*Field Methods*/
jmethodID getFieldIdMethodId;
jmethodID getFieldTypeMethodId;
......@@ -253,6 +263,7 @@ private :
void loadPacketMethodIds();
void loadProtocolRecordMethodIds();
void loadRecordMethodIds();
void loadRejectionMethodIds();
void loadFieldMethodIds();
void loadConditionMethodIds();
void loadValueTypeMethodIds();
......@@ -280,6 +291,7 @@ private :
const char *getPacketMethodSignature(const char *packetMethodName);
const char *getProtocolRecordMethodSignature(const char *protocolRecordMethodName);
const char *getRecordMethodSignature(const char *recordMethodName);
const char *getRejectionMethodSignature(const char *rejectionMethodName);
const char *getFieldMethodSignature(const char *fieldMethodName);
const char *getConditionMethodSignature(const char *conditionMethodName);
};
......
......@@ -510,6 +510,26 @@ extern "C"
return reinterpret_cast<MessageApiEndpoint *>(message)->addRejectionEntry(rejection_list, rejection);
}
struct rejection *getRejectionCopy(jlong message, struct rejection *rejection)
{
return reinterpret_cast<MessageApiEndpoint *>(message)->getRejectionCopy(rejection);
}
struct record *getRejectionRecord(jlong message, struct rejection *rejection)
{
return reinterpret_cast<MessageApiEndpoint *>(message)->getRejectionRecord(rejection);
}
struct string_list *getRejectionReasons(jlong message, struct rejection *rejection)
{
return reinterpret_cast<MessageApiEndpoint *>(message)->getRejectionReasons(rejection);
}
void addRejectionReason(jlong message, struct rejection *rejection, const char *reason)
{
return reinterpret_cast<MessageApiEndpoint *>(message)->addRejectionReason(rejection, reason);
}
/*Packet Utils*/
void addPacketRecord(jlong message, struct packet *packet, struct record *record)
{
......
......@@ -43,6 +43,10 @@ extern "C"
/*Rejection Methods*/
struct rejection_list *createRejectionList(jlong message);
void addRejectionEntry(jlong message, struct rejection_list *rejection_list, struct rejection *rejection);
struct rejection *getRejectionCopy(jlong message, struct rejection *rejection);
struct record *getRejectionRecord(jlong message, struct rejection *rejection);
struct string_list *getRejectionReasons(jlong message, struct rejection *rejection);
void addRejectionReason(jlong message, struct rejection *rejection, const char *reason);
/*Field Methods*/
const char *getFieldId(jlong message, struct field *field);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment