Catalyst FormFu DBIC error - using dot notation in a resultset [closed] - perl

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 29 days ago.
Improve this question
I've inherited a Perl Catalyst application that I'm trying to port to a new server. The application uses FormFu with the HTML::FormFu::Model::DBIC module used to load data from a result set.
I have a DBIx table, say MyTable, with an auto-generated Result implementation and a custom ResultSet implementation. In the custom ResultSet implementation there are some subroutines, e.g. sub my_sub, that return filtered subsets of data.
In a FormFu YAML file, the following will fetch all the records from MyTable:
elements:
- type: Select
model_config:
resultset: MyTable
This is equivalent to fetching, in a Controller, $schema->resultset('MyTable'). This executes correctly on both the old server and the new server.
On the old server, I can use dot notation to call the subroutine to fetch the subset of records it returns like so:
elements:
- type: Select
model_config:
resultset: MyTable.my_sub
This is equivalent to fetching in a Controller, $schema->resultset('MyTable')->my_sub. This executes correctly on the old server. On the new server, in FormFu, this throws the error:
Can't find source for MyTable.my_sub at /[...]/HTML/FormFu/Model/DBIC.pm
I've added debugging to the FormFu DBIC.pm module to see if it's doing anything special. The code it calls is $schema->resultset($rs_name); where rs_name is the name given in the resultset parameter, "MyTable.my_sub", and $schema is of type Moose::Meta::Class::__ANON__::SERIAL, which I assume is some kind of wrapper. Within a Catalyst controller, a schema is of type myapp::Schema.
What am I missing? Is there some configuration option I need to set? Some module I need to install? I can't find any documentation or examples that show a FormFu resultset with dot notation, yet on the old server it works.

When I attempted to add logging to the working DBIC.pm file, I discovered that the developer from whom I inherited this application symlinked the module's DBIC.pm file to a custom DBIC.pm file in his own home folder with the extended functionality.

Related

How to automate adding Tagged Value Types and editing of templates in Enterprise Architect [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am trying to automate the following tasks in Enterprise Architect:
Add new tagged Value types
2. Make certain changes to DDL Templates (e.g add system versioning to a table by replacing the DDL Create Table Template for MySQL with another template, that contains a "With System Versioning" clause)
Is there a way to achieve this via scripting (https://sparxsystems.com/enterprise_architect_user_guide/15.0/automation/automation_interface.html), by writing an Add In (https://sparxsystems.com/enterprise_architect_user_guide/15.1/automation/addins_2.html) or by using MDG Technologies (https://sparxsystems.com.au/enterprise_architect_user_guide/14.0/modeling_tools/mdgtechnologies_2.html) for Enterprise Architect?
Thank you in advance for all comments, answers and ideas!
Adding tagged value types is definitely possible.
I use this code in my Model wrapper
This is C#, but the translation to any other supported language such as VBScript is trivial.
public void addTaggedValueType(string tagName, string tagDescription, string tagDetail)
{
global::EA.PropertyType taggedValueType = (global::EA.PropertyType)this.wrappedModel.PropertyTypes.AddNew(tagName, "");
taggedValueType.Description = tagDescription;
taggedValueType.Detail = tagDetail;
taggedValueType.Update();
}
I don't think the API has a feature to update DDL templates directly, but you can deploy those with an MDG.
And you can include an MDG into your add-in. See this add-in class for an example
Normally tagged value types are also distributed in an MDG and not created directly by an add-in.

When should I use a Scala class and when to use Scala object in IDE? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have seen many cases where we can create a Scala project with only Scala object file and have our code inside it without the need of having a Scala class file.
I am currently working in a project where the Developer has written the code in the Scala object file (which acts as an object) instead of writing in a class file. To be more precise here is the screen shot of my IDE which shows that the code is written in an object file.
I want to know significance of writing a code in a Scala class and object file. What is the ideal scenario to use them?
There is a similar post available here which shows only the difference between a class and an object however I want to know when should I consider to use a Scala class and when to use a Scala object?
Use class when you want to create the same data structure multiple times with difference values. For example, a class could represent a row of data in a database application, or a client request in a web server.
Use object when you only need a single copy of the data structure in your program. For example, the command line for a program, or a data cache.
Classes can have short lifetimes, so use them for data that comes and goes. Objects always last until the program completes, so use them for data that needs to be available permanently.
It is reasonably straightforward to convert an object into a class, so start with an object unless you know that you are going to need multiple instances of the data.
If you just want to group similar functions or data (in a namespace), put it in an object.
If you want are writing code for a software library, use classes that can be created and deleted as required.
Note that this applies to top-level objects. An object can also be used as a class member or as a local value, but in this case it operates like a class in that it can have multiple instances and may have a limited lifetime.
An object is something that you can only have one in your program. It's most of the time used to contain functions or objects that don't change much. It's the equivalent of static in other languages
For instance:
object StringUtils {
val LF = "\n"
def toUpperCase(str: String) = str.toUpperCase()
}
// usage
StringUtils.toUpperCase("foo")
On the other hand, a class is something you can create with new. You can have several instances of a class in your program
class StringContainer(str: String) {
def toUpperCase() = new StringContainer(str.toUppercase())
}
// usage
val myString = new StringContainer("foo")
myString.toUpperCase()
For more detailed examples you can look at the scala documentation:
https://docs.scala-lang.org/tour/classes.html
https://docs.scala-lang.org/tour/singleton-objects.html
https://docs.scala-lang.org/tour/case-classes.html

UniData List all avaiable subroutines / All parameters

I am trying to wrap some UniData Subroutines to SOAP Web Service. I'm planning to use C# and UODOTNET library (IBM U2 Data Management Interface for .NET). Also I'm looking to create an engine to read all the available Subroutines from data server and also reads all the required parameters and dynamically generate required codes for Web Service.
My code would be something like this:
var session = UniObjects.OpenSession(
"192.168.0.1",
"user",
"password",
"account"
);
var cmd = session.CreateUniCommand();
cmd.Command = "LIST SUBURB.INDEX"; // ?????
cmd.Execute();
var res = cmd.Response;
Question 1: Is there any command that I can use to retrieve the list of all available subroutines?
Question 2: Is there any command that I can use to retrieve list of all parameters for specific subroutine?
Cheers
The short answer is no.
The longer answer is yes, but with a lot of work.
Since you are asking this question, I'm going to assume you are missing a lot of generally knowledge about the platform. Hence to be able to do this you'll need to:
Learn about how VOC works, specifically how executable code can be catalogued here.
Learn about the CATALOG and how cataloguing programs globally, locally and direct differ.
Understand how your system in particular is designed. Some places have everything directly catalogued in the VOC, others are a mix. If the former, it'll be easier for your question.
Once you understand the above, you'll know how to get a list of all executable programs from VOC, local catalog and global catalog. For example, a simplified example for the VOC is the UniQuery command LIST VOC WITH F1="C".
The hard part is getting the parameter list, of which there isn't any system command. To do this you have 2 options.
Reverse engineer the byte code of every subroutine and tease out the number of parameters
If you have access to the related source code, parse it to generate the list.
Just wanted to add a comment on this one, in UniData there is a MAKE.MAP.FILE command that will identify Programs and Subroutines ( and the number of parameters) which puts the information in the '_MAP_' file. This does not tell you what the parameters are used for, but it helps.

Extracting facts/objects from DefaultFactHandle in Drools StatelessKieSession (via Scala)

I've been working with Stateful Sessions (KieSession) so far and have managed to get my project running as desired using Scala with a few Java wrappers. I am now trying to switch over to StatelessKieSessions. Based on the documentation I found, I've managed to run the following to insert objects/collections into the session, fire the rules on them and update the facts:
val cmd = CommandFactory.newInsert(myObject, "myObject")
val result = ksession.execute(cmd)
When I print result (which is of class org.drools.core.common.DefaultFactHandle), it shows the structure of the desired fact, updated as expected, preceded by something of the sort "fact 0:1:2050275256:1971742898:2:DEFAULT:NON_TRAIT:"
The documentation says that I should be able to write something like result.getValue("myObject") however this option doesn't seem to be available in Scala. (https://docs.jboss.org/drools/release/6.0.0.Beta1/kie-api-javadoc/org/kie/api/runtime/StatelessKieSession.html)
I understand that Scala-Drools interoperability hasn't been provided in full, however does anyone know of a way to extract updated facts from within a StatelessKieSession or a DefaultFactHandle containing it?
What you get from this execute command is the fact handle of the newly inserted fact. The object therein would still be the one you have inserted, updated or not. You'll have to investigate whether this is something you can use in Scala or not.
There is no command to retrieve all facts that have been changed during the execution of a session. You'll have to monitor this, using some of the available technique.
There's not much to be gained by running a "Stateless Session". If you can achieve what you want using a regular (stateful) session, leave it at that. The stateless session may have its advantages, but don't grapple with it from Scala.

Compile error when setting class in VBA [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I copied code from here but I'm getting an error when trying to run the code.
The problem would be in:
Public NextItem As New queueItem
and the error message is:
user-defined type not defined
Is my VBA version not right to do this or am I doing something wrong?
You probably mean this link? The one you provided has the alternative implementation (with arrays, not with references).
I got it to work for me. Steps:
Right click on the VBA project file name, and go to Insert-> Class Module:
Click F4. The Properties window appears. Then go to the class Name and change it to Queue:
Copy and Paste the Queue Class code you found at the web site. Repeat the previous and this step for the QueueItem class (i.e., insert a Class Module, name it QueueItem and copy the code inside that class module).
This time, insert a Module using the same process (not a Class Module, but rather a simple Module). You do not need to give your module a name, Module1 will be OK.
Copy the Sub TestQueue() inside the module and run it. It should work. If you use Option Explicit on your module, you will get an error that element is undefined. So we need to define it: Dim element as Variant, under the first few Dim statements of the subroutine. Then it should run.
The above worked for me, let me know if I can be more precise, or send the file to you.