Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual creation of user defined variables #455

Open
ashah12 opened this issue Oct 18, 2024 · 2 comments
Open

Manual creation of user defined variables #455

ashah12 opened this issue Oct 18, 2024 · 2 comments
Labels
question Further information is requested

Comments

@ashah12
Copy link

ashah12 commented Oct 18, 2024

Hey development team,
I am trying to directly create a workspace for JDemetra using its Java libraries (e.g. jdplus-sa-base-workspace). I want to add Variables and userDefinedVariables.
When creating the Variables using the JD GUI, the variables show up in the XML file as dynamicTsVariable. One can add multiple of these to one item under Utilities > Variables and this shows as multiple variables in a single vars xml file.

image

I am trying to mimic this functionality using the addVariable function in the Ws class.

image

image

However, this creates one variable per file. It also creates static variables (tsVariable)- I can't see a way to create/add dynamic variables in the Ws class

image

Would you be able to guide me to better create Variables so that they all end up in one Vars xml file (perhaps mimicking the GUI process)? And could you explain the difference between static and dynamic variables?

Additionally would you be able to guide me as to how to connect the Variables with the appropriate user defined variable in each series?
Currently, I am adding a userDefinedVariable to the RegressionSpec class, with the name matching that of the Variable in the appropriate Vars.xml file:

image

But this is not producing valid workspace files and the JDemetra+ GUI doesn't appear to acknowledge the reference to the correct Variable.

@a-s-russo
Copy link

Regarding the difference between static and dynamic variables, there is a short explanation at: https://jdemetra-new-documentation.netlify.app/a-outlier-detection#generating-external-regressors:

image

@Immurb
Copy link
Member

Immurb commented Dec 4, 2024

Maybe this implementation can help for creating DynamicVariables:

public void appendTsVariables(TsCollection coll) {
for (Ts s : coll) {
String name = variables.nextName();
TsDataSupplier var;
if (s.getMoniker().isUserDefined()) {
var = new StaticTsDataSupplier(s.getData());
} else {
var = new DynamicTsDataSupplier(s.getMoniker(), s.getData());
}
variables.set(name, var);
}
((CustomTableModel) table.getModel()).fireTableStructureChanged();
}

The class as a whole is more or less the GUI implementation of Variables.

You have to create a TsMoniker to use dynamic variables. For that you can look into the providers for example jdplus-main-base/jdplus-spreadsheet-base-parent/jdplus-spreadsheet-base-api/src/main/java/jdplus/spreadsheet/base/api/SpreadSheetProvider.java

@Immurb Immurb added the question Further information is requested label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants