I have this code for gosu but it doesn't compile me for the .6 version of gosu, any ideas please - guidewire

uses ta.QueryUtil
var output: String = ""
var personIDs = new String[] {"98", "5"}
output += "***** Count the bank accounts per contact \n"
for (personID in personIDs)
{
var person = QueryUtil.findPerson(personID)
if (person != null) {
output += person.DisplayName + " has " + person.BankAccounts.length + " bank accounts. \n"
} else {
output += "person not found for " + personID + "\n"
}
}

because I am selling error when placing use ta.QueryUtil,
and also var person = QueryUtil.findPerson (personID), that's why it doesn't compile me, this pulls well in version 8 however in version 6 I don't know what I have to do
enter image description here

Related

how to get value after the record has been save?

I have an issue after saving the record in Stock Items screen, it doesn't work the way I want it to work.
I want to get the concatenated values after saving the record.
I customized the description field to concatenate the values ​​of some attributes.
I have all the following code inside RowPersisted event, the way I get that data is by using BQL query:
protected void InventoryItem_RowPersisted(PXCache cache, PXRowPersistedEventArgs e, PXRowPersisted InvokeBaseHandler)
{
string attr = "";
string itemClassDesc = "";
string itemClassCD = "";
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (InventoryItem)e.Row;
PXResultset<InventoryItem> result =
PXSelectJoin<InventoryItem,
InnerJoin<CSAnswers,
On<CSAnswers.refNoteID, Equal<InventoryItem.noteID>>,
LeftJoin<CSAttributeDetail,
On<CSAttributeDetail.attributeID, Equal<CSAnswers.attributeID>,
And<CSAttributeDetail.valueID, Equal<CSAnswers.value>>>,
InnerJoin<CSAttribute,
On<CSAttribute.attributeID, Equal<CSAnswers.attributeID>>>>>,
Where<InventoryItem.inventoryID, Equal<Current<InventoryItem.inventoryID>>>,
OrderBy<Asc<CSAnswers.attributeID>>>.Select(this.Base);
foreach (PXResult<InventoryItem, CSAnswers, CSAttributeDetail, CSAttribute> record in result)
{
InventoryItem inventory = (InventoryItem)record;
CSAnswers answers = (CSAnswers)record;
CSAttributeDetail detail = (CSAttributeDetail)record;
CSAttribute attribute = (CSAttribute)record;
switch (itemClassCD)
{
case "0531":
if (attribute.AttributeID == "A1" || attribute.AttributeID == "A2" || attribute.AttributeID == "A3")
{
if (attribute.AttributeID == "A2")
attr += answers.Value + " ";
else
if (attribute.ControlType == 1)
attr += attribute.Description + " " + answers.Value + " ";
else
attr += attribute.Description + " " + detail.Description + " ";
}
break;
default:
break;
}
}
cache.SetValue<InventoryItem.descr>(row, itemClassDesc + " " + attr);
}
It works well because the description field concatenates the values when I press the save button but it always get a previous record.
Can you help me with this?
Thanks!
The RowPersisted event is fired after the item has been saved. You need to use the RowPersisting event or override the Persist function of the graph and run your code before invoking the base function.

I have this array class that is not removing items after re-running my recyclerview

The below class is used in an array.
package com.example.ShivitoMGO;
public class RoomTable {
public String RoomName,UpDown,minmaxint;
}
Main Activity
static ArrayList <RoomTable> CountCheck = new ArrayList<>();
public void playerup(View vvv){
st_spinner = v1.findViewById(R.id.spinner);
st_reportLayout = v1.findViewById(R.id.reportlayout);
st_Leanervidimg = v1.findViewById(R.id.Linearvidcopy);
TextView roomname = v1.findViewById(R.id.action_Players1);
RoomTable roomtb = new RoomTable();
if (CountCheck.size() == 0){
//playerupdown = "up";
Toast.makeText(this, "Will notify when " + mRooms.get(position1) + " players increase #" + mRoomSize.get(position1), Toast.LENGTH_LONG).show();
String[] minmaxval = mRoomSize.get(position1).split("/");
CountCheckint = Integer.parseInt(minmaxval[0].trim());
//CountCheck = (String) mRooms.get(position1);
roomtb.RoomName = (String) mRooms.get(position1);
roomtb.minmaxint = minmaxval[0].trim();
roomtb.UpDown = "up";
Log.d("added: ", "it was added");
CountCheck.add(roomtb);
Log.d("RoomTableadd: ",roomtb.RoomName+ " " + roomtb.minmaxint +" " +roomtb.UpDown);
st_reportLayout.setVisibility(View.GONE);
Log.d("Longclickhere: ", mRoomSize.get(position1));
Log.d("RoomNameCount ", String.valueOf(CountCheck.get(0).RoomName));
}else {
int exist1 = 0;
int poss;
for (int i = 0; i < CountCheck.size(); i++) {
if (roomname.getText() == CountCheck.get(i).RoomName) {
Log.d("RoomNametxt: " , CountCheck.get(i).RoomName);
Log.d("RoomNametxt: ", (String) roomname.getText());
Toast.makeText(this, "Notification " + CountCheck.get(i).RoomName + " OFF!", Toast.LENGTH_LONG).show();
Log.d("Removed item: ", String.valueOf(CountCheck.size()));
CountCheck.remove(i);
Log.d("Removed item: ", String.valueOf(CountCheck.size()));
st_reportLayout.setVisibility(View.GONE);
exist1 = 1;
poss = i;
} else {
exist1 = 0;
}
}
if (exist1 == 0) {
Toast.makeText(this, "Will notify when " + mRooms.get(position1) + " players increase #" + mRoomSize.get(position1), Toast.LENGTH_LONG).show();
String[] minmaxval = mRoomSize.get(position1).split("/");
CountCheckint = Integer.parseInt(minmaxval[0].trim());
//CountCheck = (String) mRooms.get(position1);
roomtb.RoomName = (String) mRooms.get(position1);
roomtb.minmaxint = minmaxval[0].trim();
roomtb.UpDown = "up";
Log.d("added: ", "it was added");
CountCheck.add(roomtb);
Log.d("RoomTableadd: ", roomtb.RoomName + " " + roomtb.minmaxint + " " + roomtb.UpDown);
st_reportLayout.setVisibility(View.GONE);
}
Log.d("CountSize: ", String.valueOf(CountCheck.size()));
for (int xb = 0;xb<CountCheck.size();xb++) {
try {
Log.d("RoomNameCount ", String.valueOf(CountCheck.get(xb).RoomName));
} catch (Exception e) {
Log.d("Out of range ", String.valueOf(e));
}
}
}
}
Recycler-View
#Override
public boolean onLongClick(View v) {
// Launch your web intent
if (CountCheck.size() != 0){
Log.d("Longclickhere: ",mRoomSize.get(position));
Toast.makeText(mContext, mRoomSize.get(position), Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "Will notify when "+mRooms.get(position)+" players decrease", Toast.LENGTH_SHORT).show();
String[] minmaxval = mRoomSize.get(position).split("/");
MainActivity.CountCheckint = Integer.parseInt(minmaxval[0].trim());
} else{
//MainActivity.CountCheck = "";
Toast.makeText(mContext, "Player Decrease notification OFF", Toast.LENGTH_SHORT).show();
}
return true;
In this app the recycler view creates the "rooms" and if the room is selected the textview and 2 other values are put in to the RoomTable. these are stored and used in a service to check if ether of the other to values change. Everything works as intended unless i use the swip-to-refresh witch runs the recycler-view again. If i do not refresh and i select the same item in the recycler-view it will remove it from CountCheck . However if i run the refresh and select the same recycler-view item that i selected previously it will add it instead of removing it. This Makes no since to me because i use a for loop to Check the CountCheck.get(i).RoomName aka the textview and if the names are the same then my if statement will remove instead of add. is it somehow possible i'm ending up with 2 CountCheck Objects????? with the same name???? Please I'm out of ideas on this one. Thanks.
I dont remember why. Maybe someone can explain but i changed this line
if (roomname.getText() == CountCheck.get(i).RoomName)
To this
if (roomname.getText().equals(CountCheck.get(i).RoomName));
and that fixed the issue. please let me know the difference if you are reading this.

Issues in indexing or querying

every one I m a beginner with Big Data and trying to index and search the data. I have a problem
1)- While indexing program runs very smoothly but while Searching It always shows one or zero hit per query.
Like this:-
Skipped write.lock
Added: D:\Studies\Universities-Punjab University-\Notes\Final Year Project\Appache Lucene\Result 3\file.txt
Added: D:\Studies\Universities-Punjab University-\Notes\Final Year Project\Appache Lucene\Result 3\lab 1.txt
2 Documents Added.
Enter the Search Query (q=quit):
Waleed
Found 1 hits.
D:\Studies\Universities-Punjab University-\Notes\Final Year Project\Appache Lucene\Result 3\file.txt score=0.0390625
Enter the Search Query (q=quit):
Wlaeed
Found 0 hits.
Enter the Search Query (q=quit):
Ahmad
Found 1 hits.
D:\Studies\Universities-Punjab University-\Notes\Final Year Project\Appache Lucene\Result 3\file.txt score=0.0390625
Enter the Search Query (q=quit):
train
Found 1 hits.
D:\Studies\Universities-Punjab University-\Notes\Final Year Project\Appache Lucene\Result 3\lab 1.txt score=0.17900687
Enter the Search Query (q=quit):
q
Code for Indexing:-
Reader fr = null;
try {
Document doc = new Document();
fr = new FileReader(f);
doc.add(new StringField("path", f.getPath(), Field.Store.YES));
doc.add(new StringField("filename", f.getName(),Field.Store.YES));
doc.add(new TextField("contents", fr));
writer.addDocument(doc);
enhanceList(f, helper);
} catch (Exception e) {
System.out.println("Could Not Add: " + f);
} finally {
fr.close();
}
Code for Searching/Querying:-
void searching() throws IOException {
String s = "";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
IndexReader reader = DirectoryReader.open(FSDirectory.open(new File(directory)));
IndexSearcher searcher = new IndexSearcher(reader);
while (!s.equalsIgnoreCase("q")) {
try {
System.out.println("Enter the Search Query (q=quit):");
s = br.readLine();
if (s.equalsIgnoreCase("q")) {
break;
}
Query q = new QueryParser(Version.LUCENE_44, "contents", analyzer).parse(s);
ScoreDoc[] hits = searcher.search(q, 1000).scoreDocs;
System.out.println("Found " + hits.length + " hits.");
for (int i = 0; i < hits.length; i++) {
int docId = hits[i].doc;
Document d = searcher.doc(docId);
System.out.println((i + 1) + ". " + d.get("path") + " score=" + hits[i].score);
}
} catch (Exception e) {
System.out.println("Error Searching " + s + " : " + e.getMessage());
}
}
}
Please any body help me out in finding out the solution..

Calculating totalCost

Ok below is my code for a class I am taking... I need to know how to properly code the totalCost for this product and I can not for the life of me figure out how to properly do this. The price per product is $1 and I need to calculate a 7% sales tax as well. Help!!!
import javax.swing.JOptionPane;
/**
* #author bary
*/
public class CocaCola1 {
public static void main(String[] args)
{
String openingMsg = "*** Welcome to CocaCola Online Ordering System ***\n"
+ "Do yourself a favor and order some Cola... NOW!";
JOptionPane.showMessageDialog(null, openingMsg);
System.out.println(0);
String name = getUserInput("What is your name?");
System.out.println(name);
String returnCustomer = getUserInput("Are you a returning customer? (yes/no)");
System.out.println(returnCustomer);
String orderType = getUserInput("Would you like to purchase Dasani, Coke, Diet Coke, or Cherry Coke?");
System.out.println(orderType);
String orderAmount = getUserInput("How many units would you like to purchase?");
System.out.println(orderAmount);
Integer.parseInt(orderAmount);
// each unit costs $1.00 so orderAmount is equal to cost per unit
double salesTax = 0.7;
// create and display output string
String outputMsg
= "Hello " + name + ".\n\n" +
"Your return customer status is " + returnCustomer + ".\n" +
"You ordered " + orderAmount +
" units of " + orderType + ".\n" +
"Your total cost is $" + orderAmount + salesTax + ".\n" +
"Thank you for visiting CocaCola" + ".\n\n" +
"Your order will be proccessed ASAP.\n";
JOptionPane.showMessageDialog(null, outputMsg);
}
private static String getUserInput(String prompt)
{
int failCount = 0;
do
{
String answer = JOptionPane.showInputDialog(prompt);
if (answer == null)
{
System.exit(0);
}
answer = answer.trim();
if (answer.isEmpty())
{
JOptionPane.showMessageDialog(null, "You must provide a non-blank answer");
failCount = failCount + 1;
} else
{
return answer;
}
} while (failCount < 3);
JOptionPane.showMessageDialog(null, "You failed three times to provide input... Try again later!");
System.exit(0);
return null; // means nothing, as I just exited on the prior line, but need it to compile
} // end main()
} // end class CocaCola1
orderAmount + salesTax would only be if the sales tax was static. You need to multiply the orderAmount by the sales tax and add salestax
ex: orderAmount*salesTax+prderAmount
or set salesTax to 1.7 and it would be
orderAmount*salesTax

Subsonic - Simple Query

I have a table has 2 columns
Val1 int
Val2 int
My query very simple.
I want to get collection of record have condition (val1=Val2) ,
equivalent to (Select * from table where Val1=Val2)
I try
IDataReader rdr = new Query("Table").WHERE("Val1=Val2").ExecuteReader();
tableColl.LoadAndCloseReader(rdr);
rdr.Close();
and
..WHERE (" 'Val1=Val2' ")
..WHERE (Table.Columns.Val1,IsEqualTo,Table.Columns.Val2) //This not reguler I know
..WHERE ("Val"+'='+"Val2")
.....
any help be more apricated.
Thanks.
Unfortunately you'll need to do this as an inline query as far as I know:
TableCollection tableCollection = new InlineQuery()
.ExecuteAsCollection<TableCollection>(
"SELECT * FROM " + Table.Schema.TableName " WHERE " + Table.Columns.Val1 + " = " + Table.Columns.Val2);
was in same situation recently and came up with this:
TableCollection tablecollection = new TableCollection;
Comparison comp = Comparison.Equals;
tablecollection.Where(Table.Columns.Val1, comp, Table.Columns.Val2);
tablecollection.Load();
i found this better because i don't like inline queries. and it gives
more flexibility if you wish to allow for adhoc querying in you app.
private void CreateDynamicControls()
{
panGvHolder.Controls.Clear();
Query qry = Northwind.Product.CreateQuery();
qry.Columns.AddRange(Northwind.Product.Schema.Columns);
qry.WHERE("UnitPrice > 15").AND("UnitsInStock < 20 ");
//WHERE("UnitPrice > 15").AND("UnitsInStock < 30 ");
using (IDataReader rdr = qry.ExecuteReader())
{
Response.Write("<table>");
while (rdr.Read())
{
Response.Write("<tr>");
for (int i = 0; i < rdr.FieldCount; i++)
{
Response.Write("<td>");
Response.Write(rdr[i].ToString() + " ");
Response.Write("<td>");
} //eof for
Response.Write("</br>");
Response.Write("</tr>");
}
Response.Write("<table>");
}
} //eof method

Resources