input external parameters java fx - input

I need to run a program from the command line. There should be two inputs. username and password.
My problem is that I cannot find a clean easy way to do it. Either my syntax in the CMD console is bad or my code...
My code looks like this:
stage.setScene(scene);
stage.setTitle("Bmi Calculator");
stage.setResizable(false);
final Parameters params = getParameters();
final List<String> parameters = params.getRaw();
BMI.username = parameters.get(0);
BMI.password = parameters.get(1);
stage.show();
The problem is catching the input. I'm trying to set the variables from the main class to the two public static variables in my contoller class.
My CMD input would look like this:
Start BmiCalculator.jar e:\Desktop\BmiCalculator.jar username password
// Alex

Related

Replacing Type with var for all 'Class class = new Class()' usages in Java project

I recently switched to Java 11 for a rather big project, and would like to switch to using var class = new Class() instead of Class class = new CLass().
I tried using Intellij Structural Search (and replace) for this, but its turning out to be more complex than expected.
My first attempt was $Type$ $Inst$ = new $Constructor$($Argument$);, which also matches global variables (which don't allow var).
My second attempt is:
class $Class$ {
$ReturnType$ $Method$ ($ParameterType$ $Parameter$) throws $ExceptionType$ {
$Statements$;
final $Type$ $Inst$ = new $Constructor$($Argument$);
$Statements2$;
}
}
Which misses all calls inside e.g. try blocks (since they get matched by the expressions)
Any help would be greatly appreciated!
Use your first template
$Type$ $Inst$ = new $Constructor$($Argument$);
But add a Script modifier on the $Inst$ variable with the following text:
Inst instanceof com.intellij.psi.PsiLocalVariable
Alternatively you may want to try the Local variable type can be omitted inspection that is available in IntelliJ IDEA.

Recieving user input with slash command Discord.Net

Is there a way to receive user inputted data using the current format I have, I have seen that there is a way to do it using the slashCommandBuilder as seen here discord.net how to get user input data on slash command option? , an example of my slash command is
[SlashCommand("ping", "ping pong")]
public async Task HandlePing()
{
await RespondAsync("pong!");
}
I'd like to be able to use user input eg: user inputs /ping dog and it prints dog
there was another post like this; use the following code:
public async Task HandlePing(SocketSlashCommand command)
{
var userInput = command.Data.Options.First().Value.ToString();
await command.RespondAsync("pong!");
}
If your input is IUser, or an int, remove ToString() at the end of the variable, userInput

is there a way to pass data directly in Step definition without passing in feature file?

i want to use dataprovider to pass data directly into step definition without passing from feature file, as i want to pass null values as well. here is what i am doing.
Scenario: User should get empty field highlight, when that fields is empty and clicked submit. When Submit is clicked after providing values in nethier or either of Reg Id or PC
#Test(dataProvider = "getData")
#When("^Submit is clicked after providing values in nethier or either of Reg Id or PC$")
public void submit_is_clicked_after_providing_values_in_nethier_or_either_of_reg_id_something_or_pc_something(
String regvalue, String pcvalue) throws Throwable {
//code
}
#DataProvider
public Object[][] getData() {
Object[][] data = new Object[3][2]; // 3 is number of combinations and 2 is number of values
// 1st set
data[0][0] = "Username1";
data[0][1] = null;
// 2nd set
data[1][0] = null;
data[1][1] = "Password1";
// 3nd set
data[2][0] = null;
data[2][1] = null;
return data;
}
Error i am getting is
Step [^Submit is clicked after providing values in nethier or either of Reg Id or PC$] is defined with 2 parameters at 'com.commcard.stepdefinition.StepDef.submit_is_clicked_after_providing_values_in_nethier_or_either_of_reg_id_something_or_pc_something(String,String) in file:/D:/Eclipse-Workspace/CucumberProject.CitiCommCard/target/test-classes/'.
However, the gherkin step has 0 arguments.
You can use a yml file as a data-lookup. For JSON style testing I would advocate this. As you can use a regular fixture or build it up mid-process.
So you could have something like this.
Given I have a valid request to create a user
But the username is invalid
Given I have a valid request to create a user
But the username is too short
# yaml file
user:
create:
issues:
username:
invalid: "Can't Use W3!rd char$"
too_short: "usrnm"
Then your steps just use whatever programming language you use and convert the yml into a data lookup (Hash/List), and alter the keys.

How to pass Model as an argument in a method ActiveJDBC

Can I pass Model as an argument in a method using ActiveJDBC?
Something like this:
public Set<String> getColNames(Model modelName){
Set<String> set = modelName.attributeNames();
for(String x: set){
System.out.prtinln(x);
}
return set;
}
That way I can just pass the model and would save a lot of time on doing the same code on each Model right?
Like this:
Staff staff = new Staff();
Set<String> set = getColNames(staff);
Is this possible??? Getting the attribute names is just an great example on this, this is not only the purpose why I asked this.
Help would be appreciated!
If you could explain why you need this, it would be easier to give directions.
In any case, you can do this with one line of code;
Map values = model.toMap();
See: Model#toMap()
I think that what Igor means, is that you can build your own static method, on a class called Util. This method would be something like this.
public static Set<String > getColNames(Model model) {
return model.toMap().keySet();
}
Then, you can use it like this:
Staff staff = new Staff();
Set<String> set = Util.getColNames(staff);

Print SSRSReport to file (.PDF)

I need to find a way to "print" a SrsReport, in my case SalesInvoice, as .PDF (or any kind of file) to a specific location.
For this I modified the SRSPrintDestinationSettings to output the SalesInvoice-Report as a .PDF:
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(#'\\AXDEV\Bottomline\Test\test.pdf');
Somehow this gets ignored and I recive a Email with the report as .PDF attached.
For example this will run on ax 2012 but won't print to PDF for me.
SRSPrintDestinationSettings settings;
CustInvoiceJour custInvoiceJour;
SrsReportRunController controller = new SrsReportRunController();
PurchPurchaseOrderContract rdpContract = new PurchPurchaseOrderContract();
SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();
select firstOnly1 * from custInvoiceJour where custInvoiceJour.SalesId != "";
// Define report and report design to use
controller.parmReportName(ssrsReportStr(SalesInvoice,Report));
// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
rdpContract.parmRecordId(custInvoiceJour.RecId);
controller.parmReportContract().parmRdpContract(rdpContract);
// Explicitly provide all required parameters
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
controller.parmReportContract().parmRdpContract(salesInvoiceContract);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(#'\\AXDEV\Bottomline\Test\test.pdf');
//tokens = settings as SrsPrintDestinationTokens();
//controller.parmPrintDestinationTokens(null);
//Suppress report dialog
controller.parmShowDialog(false);
// Execute the report
controller.startOperation();
Questions:
Is this the correct way to print a srsReport to .pdf?
Am I passing/setting the printerSettings correctly?
Where does it say "Send Email"?
EDIT: Code is working fine. We are using external code of a company which simply doesnt implement this.
Use the cleaner code of Alex Kwitny
Here is working code for me. I just quickly coded this from scratch/memory based off of glancing at yours, so compare for differences.
I have two things marked (1) and (2) for you to try with your code, or just copy/paste mine.
static void JobSendToPDFInvoice(Args _args)
{
SrsReportRunController controller = new SrsReportRunController();
SRSPrintDestinationSettings settings;
CustInvoiceJour custInvoiceJour = CustInvoiceJour::findRecId(5637925275);
SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();
Args args = new Args();
controller.parmReportName(ssrsReportStr(SalesInvoice, Report));
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
controller.parmShowDialog(false);
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId);
salesInvoiceContract.parmDocumentTitle(CustInvoiceJour.InvoiceId);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
// (1) Try by passing args
args.record(custInvoiceJour);
args.parmEnum(PrintCopyOriginal::Original);
args.parmEnumType(enumNum(PrintCopyOriginal));
controller.parmReportContract().parmRdpContract(salesInvoiceContract);
controller.parmArgs(args);
// (2) Try explicitly preventing loading from last value
// controller.parmLoadFromSysLastValue(false);
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(#'C:\Temp\Invoice.pdf');
controller.startOperation();
}
Since you are talking about the sales invoice the report is using the print management feature and you cannot simply override the print settings like that.
You need to override the runPrintMgmt on the controller class and determine there whether you want default print management or your own code.
See this post for an example: http://www.winfosoft.com/blog/microsoft-dynamics-ax/manipulating-printer-settings-with-x