QuickfixJ required field missing, even if it's there - java

I'm getting a "Conditionally Required Field Missing" error message, even though I'm sure that field is there.
58=Conditionally Required Field Missing, field=55
Versions:
QuickFixJ 2.1.0
FIX 4.4
Here is the FIX message that I'm sending (with mocked values and a few fields removed for clarity)
8=FIX.4.4
9=709
35=R
34=4
49=TARGET
56=ME
11=myClOrdID
131=myQuoteReqID
146=myNoRelatedSym
55=mySymbol // field missing
167=mySecurityType // field missing
Here is the calling code:
String symbol = quoteRequest.getField(new StringField(55)).getValue();
I also tried:
String symbol = quoteRequest.getString(55);
Here is my Data Dictionary:
<field number="55" name="Symbol" type="STRING"/>
I realize that the symbol field is no longer a part of the QuoteRequest FIX specification for 4.4 (though it was in earlier versions, such as 4.0), however surely there are ways to retrieve custom fields? I have no control over the QuoteRequest message that I receive.
I can always parse the message myself using toString() but that kinda defeats the purpose of using quickfixj in the first place.
Any ideas?

Tag 55 is inside the 146 repeating group. See the docs for reading repeating groups.
The symbol field is still in FIX44. You should spend some time familiarizing yourself with the FIX44.xml data dictionary file that you're using.
(You may find that you need to customize that file based on your counterparty's messaging; in practice, nobody uses the basic FIX44 message definitions without changing them at least a little.)

// create group
QuoteRequest.NoRelatedSym group = new QuoteRequest.NoRelatedSym();
// set group, confusing method name I find
message.getGroup(1, group);
// you now have all the getters of fields in that group
Symbol symbol = group.getSymbol();

Related

Apache POI "cannot access CTSkip"

I'm encountering an issue trying to use Apache POI 5.2.3. I'm attempting to set the category axis mark interval and label.
As mentioned in another question(https://stackoverflow.com/a/66670362/2212458). The following code is supposed to handle this:
chart.getCTChart().getPlotArea().getCatAxArray(0).addNewTickLblSkip().setVal(2); // label only every second mark
chart.getCTChart().getPlotArea().getCatAxArray(0).addNewTickMarkSkip().setVal(2); // show only every second mark
However, this results in a build error "error: cannot access CTSkip" and "class file for org.openxmlformats.schemas.drawingml.x2006.chart.CTSkip not found".
Other portions of the namespace are accessible such as CTTitle, CTNumFormat, CTTickMark are accessible, but for some reason CTSkip is not. How do I work around this issue?

How to use String ressource in Java file in Android without a Layout

I have a Java class that mainly contains strings. It does not have a layout as it is neither a Fragment nor an Activity. It is more used as an auxilliary class. I would like to assign the String values in the class by using the Resource strings as I would like to automatically translate the Strings. Howvever, I can't access the string resources from Java. I use the following code:
static String more = getString(R.string.more);
And in the XML file I have the ressource:
<string name="more">More</string>
I get the error message
Cannot resolve method 'getString'
I also tried static String more = getContext().getString(R.string.more);
but I got the error message:
Cannot resolve method 'getContext'
Would anyone mind helping me on that? I'd appreciate every comment.
Update: I tried to use the answer from "MikaelM"
Resources.getSystem().getString(R.string.more)
However, I get an "exception in initializer error" and when I use the initial String again, I do not get this error. So I still can't get the String from the ressource. DO you have an idea what I can do? I'd appreciate every further comment.
So the error is caused by "Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f120038"
The strange thing is that the resource in fact exists (I checked this several times).
getString(R.string...
is not the same as
Resources.getSystem().getString(android.R.string...
Only the second variant you can use in the static context. Alas, you can get this way only system resources.
If you need to get your own resources, no one-line solution exists. Use https://stackoverflow.com/a/4391811/715269 solution of #Cristian. And notice: it is a very good solution, even more, it is the solution meant to be used by the creators of Android.
You should be able to get your string with:
Resources.getSystem().getString(R.string.more)
See more here, getString Outside of a Context or Activity

HL7 - Assigned Patient Location

I must generate HL7 file but i 'm facing problem with PV1 segment.
I don't find how to set Facility variable with my value
i use hapi but i don't find their java method that allows that...
i succed for setting PV1-9 Consulting doctor field :
msg.getPV1().insertConsultingDoctor(0).getGivenName().setValue(nomMedecin);
but there is no insertXxx method for setting PV1-3.4 field, just one to get the value :
msg.getPV1().getPv13_AssignedPatientLocation().getFacility();
The API of HAPI is a bit unusual since most of the times, there is no need to instantiate objects. Just calling the get method gives you an object:
HD facility = msg.getPV1().getPv13_AssignedPatientLocation().getPl4_Facility();
This gives you an instance of HD which has more segments:
ST universalID = facility.getHd2_UniversalID();
Once you are down to a String (ST) data type, you can set a value:
universalID.setValue("FooBar");

Thymeleaf add custom data attribute with message resource value

I have a requirement where I need to insert the value to custom data tag using thymeleaf. The code for doing it using
data-th-attr="${data-custom=#messages.msg('test')}"
as well as
th:attr="data-custom=${#messages.msg('test')}"
I am unable to get the value in both the cases.
ultimately the parsing should be like data-custom="test"
here test is key for the value test in a properties file
By using the
data-th-attr="data-custom=#{test}"
or By using
th:attr="data-custom=#{test}"
helped me out, here test is the key for the value in message resource the issue was with the intellij IDEA IDE, it was having a bug that was showing me an unnecessary error.
Use th:attr="data-custom=#{key.for.message}" , this should work.
then after parsing the Expression,
data-custom="value.for.message"

find by Object Id in Jongo

I know this question is incredibly basic... I'm sorry in advance.
I can't do a 'find by ID' for Mongo using Jongo.
I tried
Iterator<MongoTest> all = db.getCollection("mongoTest").find("{'_id': ObjectId('5194d46bdda2de09c656b64b')}").as(MongoTest.class).iterator();
Error:
java.lang.IllegalArgumentException: {'_id': ObjectId('5194d46bdda2de09c656b64b')} cannot be parsed
at org.jongo.query.JsonQuery.marshallQuery(JsonQuery.java:34)
at org.jongo.query.JsonQuery.<init>(JsonQuery.java:27)
at org.jongo.query.JsonQueryFactory.createQuery(JsonQueryFactory.java:52)
at org.jongo.Find.<init>(Find.java:41)
at org.jongo.MongoCollection.find(MongoCollection.java:79)
at org.jongo.MongoCollection.find(MongoCollection.java:75)
I tried
Iterator<MongoTest> all = db.getCollection("mongoTest").find(withOid(new ObjectId("5194d46bdda2de09c656b64b"))).as(MongoTest.class).iterator();
exactly as in the documentation, and I can't even get it to compile ... there are two possible types of ObjectId.
de.undercouch.bson4jackson.types.ObjectId;
Tells me
The constructor ObjectId(String) is undefined
And if I use
org.bson.types.ObjectId;
it seems to work better, sometimes - but it still tells me that withOid( ObjectId ) is undefined. Which isn't entirely surprising, cause exactly what object is that function supposed to be part of?
My question: How do I do a find by _id in Jongo?
Someone helped me to find an answer elsewhere, putting it here for posterity
A valid construction for this is
db.getCollection("mongoTest")
.find("{ _id: # }", new ObjectId("5194d46bdda2de09c656b64b"))
.as(MongoTest.class);
Using org.bson.types.ObjectId
or
db.getCollection("mongoTest")
.findOne(Oid.withOid("5194d46bdda2de09c656b64b"))
.as(MongoTest.class);`

Categories