We have a requirement of custom traits and the data for the custom trait should be fetched from our rest API.
Examples for traits we are looking into are like : Balance, Currency, Birthday etc.(Should be dynamic).
Business wants the ability to add a new custom trait from the configuration, with the data available from the rest api.
In case if we add new data items in the rest api we should be able to configure and use that custom trait corresponding to that data.
For this requirement,
I had gone through the Silver pop & Sugar CRM modules,
It seems like complexity involved to understand the login and external forms.
I have added some generic class implementation. But still I am not able to populate the traits in the Magnolia with data from rest.
I need few more clarifications regarding this.
1.How Magnolia recognizes the trait. Through Configuration/ something else(XML)?
2.If I try to generate the configuration with the static values in the version handler and called register methods by passing the tasks as parameters in the constructor. But still I am unable to see the trait configuration in the admin central.(config.modules.rest-traits-module.traits.balance.xml, config.modules.rest-traits-module.traits.currency.xml). Can we generate this kind of configuration as dynamic in Java code?
3.How can we set labels for the Traits instead of adding in Properties file? because we need them as dynamic.
4.Can we generate dynamic yaml files through java?(For traits configuration) If yes, does it support for Magnolia 5.3.9?
In the silver pop module they given some external form and its actions.. In my requirement i am not using any external forms? How can I proceed?
Does login is mandatory for this requirement?
Could you please suggest.
Thanks for your support,
--Vijay Kodali.
1.How Magnolia recognizes the trait.
You register the trait in the traits folder under your module. See documentation on creating custom traits for more info.
Can we generate this kind of configuration as dynamic in Java code?
Yes you can. Perhaps you made mistake somewhere in your version handler? Or it was not called because your module is already installed? Hard to say without seeing the code.
3.How can we set labels for the Traits instead of adding in Properties file? because we need them as dynamic.
not really "trait specific", but general Magnolia/Vaadin UI question. If you want to set labels dynamically, you would need to write your own FormPresenter (or View) implementation.
4.Can we generate dynamic yaml files through java?(For traits configuration) If yes, does it support for Magnolia 5.3.9?
Yes, you can generate yaml files through java. It doesn't matter what/whom puts them in filesystem as long as they are on observed file path.
And no, you can't register traits via yaml (yet) no matter which version of Magnolia you use. And in general yaml support is since 5.4 only, so it would not work on 5.3.9 anyway.
In my requirement i am not using any external forms? How can I proceed?
Traits have no direct connection to external forms. Those two are independent feature. In silverpop/marketing-cloud module they were used together since Magnolia was both producing data for Silverpop and consuming data from it, but you can have custom traits even without external forms. For more details see the above mentioned documentation on creation of custom traits.
Does login is mandatory for this requirement?
No login is not mandatory.
HTH,
Jan
Related
I'm creating a template for our server-side codegen implementation, but I ran into an issue for a feature request...
The developers who are going to use the generated base want the following pattern (the generator is based on the dotnetcore):
Controllers
v{apiVersion}
{endpoint}ApiController : Controller, I{endpoint}Api
Interfaces
v{apiVersion}
I{endpoint}Api
I{endpoint}DataProvider
DataProviders
-v{apiVersion}
-{endpoint}DataProvider : I{endpoint}DataProvider
Both interfaces are the same, describing the endpoints. The DataProvider implementation will allow us to use DI to hot-swap the actual data provider/business logic layer during runtime.
The generated ApiControllers will refer to the IDataProviders, and use the actual implementation (the currently active one, that is). For that we're going to use dotnetcore's built-in dependency injection system.
However I can't seem to find a way to have the operations generator output to three different folders, based on the template. It will all end up jumbled in a single folder, and I will need to manually move them.
Is there a way to solve these requirements, or should I solve it all the time manually?
We have a requirement to allow customising our core product and adding additional fields on a per client basis e.g. People entity some client wants to record their favourite colour etc. As far as I know we can't add properties to EF at runtime as it needs classes defined at startup. Each customer has their own database but we are deploying the same solution to all customers with all additional code. We are then detecting which customer they are and running customer specific services etc.
Now the last thing I want is to be forking my project or alternatively adding all fields for all clients. This would seem likely to become a nightmare. Also more often than not the extra fields would only be required in a very limited amount of place. Maybe some reports, couple of screens etc.
I found this article from Jermey Miller http://codebetter.com/jeremymiller/2010/02/16/our-extension-properties-story/ describing how they are adding extension properties and having them go from domain to the web front end.
Has anyone else implemented anything similar using EF? How did it work out? Are there any blogs/samples that anyone has seen? I am not sure if I am searching for the right thing even if someone could tell me the generic name for what we want to do that would help. I'm guessing it is a problem that comes up for other people.
Linked question still requires some forking or implementing all possible extensions in single solution because you are still creating strongly typed extensions upfront (= you know upfront what extensions customer wants). It is not generally extensible solution. If you want generic extensible solution you must leave strongly typed world and describe extensions as data.
You will need to use some metamodel. Your entity classes will contain only properties used by all customers and navigation property to special extension entity (additional table per every extensible entity) where you will be able to put additional properties as name / value pair (you can add other columns like type, validation, etc. if needed).
This will in general moves part of your model from hardcoded scenario to configuration based scenario and your customers will even be allowed to define extensions at runtime (if you implement such feature).
In the recent spirit of isolating stuff and plugging it in via NuGet, does anyone have an idea about how you'd limit a dependency resolver to just one area in MVC3? It's easy enough to keep views and controllers limited to an area, but unless I'm not seeing an obvious hook, it looks like setting an IDependencyResolver is something that unavoidably has global scope. I'd like to limit it to just one area.
Any suggestions?
IDependencyResolver is global by design. If you want to vary behavior by area, you should look at the various *Activator types and interfaces that can make decisions based on context objects.
What specifically are you trying to do?
I would suggest using the Common Service Locator for this. Basically each area could setup up the CSL for their specific container.
You will probably need to create an adapter between the dependency resolver or forgo it altogether and strictly use the CSL.
In general I am not a proponent of using the CSL in a line of business app. It's intent is to make it easier for open source components that use DI (like MassTransit) easier to integrate into line of business apps. This might be an exception however.
Also, look into the mvccontrib portable areas. It's designed for this type of thing.
What you're trying to do sounds like a bad idea. The point of dependency injection is so you can isolate specific dependencies and not have your code care where they come from.
If you're trying to restrict some objects or classes to a certain MVC area, configure your dependency injector to call the proper ones at the right time.
Some more details about what you're trying to do will help generate better answers.
We're currently migrating our ASP Intranet to .NET and we started to develop this Intranet in one ASP.NET website. This, however, raised some problems regarding Visual Studio (performance, compile-time, ...).
Because our Intranet basically exists of modules, we want to seperate our project in subprojects in Visual Studio (each module is a subproject).
This raises also some problems because the modules have references to each other.
Module X uses Module Y and vice versa... (circular dependencies).
What's the best way to develop such an Intranet?
I'll will give an example because it's difficult to explain.
We have a module to maintain our employees. Each employee has different documents (a contract, documents created by the employee, ...).
All documents inside our Intranet our maintained by a document module.
The employee-module needs to reference the document-module.
What if in the future I need to reference the employee-module in the document-module?
What's the best way to solve this?
It sounds to me like you have two problems.
First you need to break the business orientated functionality of the system down into cohesive parts; in terms of Object Orientated design there's a few principles which you should be using to guide your thinking:
Common Reuse Principle
Common Closure Principle
The idea is that things which are closely related, to the extent that 'if one needs to be changed, they all are likely to need to be changed'.
Single Responsibility Principle
Don't try to have a component do to much.
I think you also need to look at you dependency structure more closely - as soon as you start getting circular references it's probably a sign that you haven't broken the various "things" apart correctly. Maybe you need to understand the problem domain more? It's a common problem - well, not so much a problem as simply a part of designing complex systems.
Once you get this sorted out it will make the second part much easier: system architecture and design.
Luckily there's already a lot of existing material on plugins, try searching by tag, e.g:
https://stackoverflow.com/questions/tagged/plugins+.net
https://stackoverflow.com/questions/tagged/plugins+architecture
Edit:
Assets is defined in a different module than employees. But the Assets-class defines a property 'AssignedTo' which is of the type 'Employee'. I've been breaking my head how to disconnect these two
There two parts to this, and you might want to look at using both:
Using a Common Layer containing simple data structures that all parts of the system can share.
Using Interfaces.
Common Layer / POCO's
POCO stands for "Plain Old CLR Objects", the idea is that POCO's are a simple data structures that you can use for exchanging information between layers - or in your case between modules that need to remain loosely Coupled. POCO's don't contain any business logic. Treat them like you'd treat the String or DateTime types.
So rather than referencing each other, the Asset and Employee classes reference the POCO's.
The idea is to define these in a common assembly that the rest of your application / modules can reference. The assembly which defines these needs to be devoid of unwanted dependencies - which should be easy enough.
Interfaces
This is pretty much the same, but instead of referring to a concrete object (like a POCO) you refer to an interface. These interfaces would be defined in a similar fashion to the POCO's described above (common assembly, no dependencies).
You'd then use a Factory to go and load up the concrete object at runtime. This is basically Dependency Inversion.
So rather than referencing each other, the Asset and Employee classes reference the interfaces, and concrete implementations are instantiated at runtime.
This article might be of assistance for both of the options above: An Introduction to Dependency Inversion
Edit:
I've got the following method GetAsset( int assetID ); In this method, the property asset.AssignedTo (type IAssignable) is filled in. How can I assign this properly?
This depends on where the logic sits, and how you want to architect things.
If you have a Business Logic (BL) Layer - which is mainly a comprehensive Domain Model (DM) (of which both Asset and Employee were members), then it's likely Assets and Members would know about each other, and when you did a call to populate the Asset you'd probably get the appropriate Employee data as well. In this case the BL / DM is asking for the data - not isolated Asset and Member classes.
In this case your "modules" would be another layer that was built on top of the BL / DM described above.
I variation on this is that inside GetAsset() you only get asset data, and atsome point after that you get the employee data separately. No matter how loosely you couple things there is going to have to be some point at which you define the connection between Asset and Employee, even if it's just in data.
This suggests some sort of Register Pattern, a place where "connections" are defined, and anytime you deal with a type which is 'IAssignable' you know you need to check the register for any possible assignments.
I would look into creating interfaces for your plug-ins that way you will be able to add new modules, and as long as they follow the interface specifications your projects will be able to call them without explicitly knowing anything about them.
We use this to create plug-ins for our application. Each plugin in encapsulated in user control that implements a specific interface, then we add new modules whenever we want, and because they are user controls we can store the path to the control in the database, and use load control to load them, and we use the interface to manipulate them, the page that loads them doesn't need to know anything about what they do.
I have seen questions here asking about xsd->actionscript objects, but these seem to require xsd->java->actionscript and is all in source code. Our requirements are a bit different:
receive an xsd during runtime that we have never seen before
Create an instance object based on the xsd
fill in the values of the instance (either from an xml document or user input - whatever)
Anyone know of an actionscript library or tool that would help us accomplish this at runtime? It would be nice if something like this already existed - but we would certainly settle for a library that gave us a programmatic interface to extract information from an xsd schema. Additionally, we would take suggestions on alternate methods to accomplish the same ends.
Have you looked at the SchemaLaoder...? Not EXACTLY what you're looking for ... But a great start.
First - you should check this blog entry and this blog entry which walks you through Dominic De Lorenzo experiences with utilising functionality within the Flex SDK that provides the automatic mapping of custom ActionScript classes to element definitions within an XML Schema (XSD).
The steps to get moving here include (from Dominic's blog):
0) Create an instance of SchemaLoader and asynchronously load an XML schema from a given URL
1) Once the schema is loaded, add it to the SchemaManager and register any ActionScript classes to their corresponding schema type
---- At this stage you can do several operation based on the schema
2) Load an XML file based off that schema
3) Once the XML is loaded, decode the contents using XMLDecoder. Any classes registered in the schemaTypeRegistry will be used when decoding the xml
4) Encode a custom ActionScript class back into XML using XMLEncoder. XMLEncoder.encode() supports various ways to define the corresponding element in the schema (top level element, a specific type or even a custom XSD definition) that will be used to encode the Actionscript object.
The blog entry has links to code samples, etc...
Hope this helps.