Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# D3grade 10/17/2007 3:29 PM
Hi Guys,

I'm currently working on a module similar to the articles module however it is split into 2 modules. The main one which stores the articles and displays a list of them, and an articles details module which shows the details of an article.

What i want to be able to do is get the article details module to read the settings of the main articles module it is linked with, and also be able to link back to it's parent section.

I thought i might be able to do this by looking in the Module.Section.Connections collection, although it seems to be empty for the article details module. Is this correct? is it only the actionProvider that has a reference to the actionConsumer module? or should it be 2 way?

Cheers

Matt
# martijnb 10/17/2007 9:24 PM
To make a 2 way connection between the Articles and ArticleDetails modules you should implement IActionProvider and IActionConsumer on both modules.

For example:
Articles module:
public ActionCollection GetOutboundActions()
{
	ActionCollection actions = new ActionCollection();
	actions.Add(new Action("ViewDetails", new string[1] {"ArticleId"}));
	return actions;
}

public ActionCollection GetInboundActions()
{
	ActionCollection actions = new ActionCollection();
	actions.Add(new Action("ViewArticles", null));
	return actions;
}

And the ArticleDetails module:
public ActionCollection GetOutboundActions()
{
	ActionCollection actions = new ActionCollection();
	actions.Add(new Action("ViewArticles", null));
	return actions;
}

public ActionCollection GetInboundActions()
{
	ActionCollection actions = new ActionCollection();
	actions.Add(new Action("ViewDetails", new string[1] {"ArticleId"}));
	return actions;
}

Now, you can read the settings from the Articles module in the ArticleDetails module via:
IDictionary articleModuleSettings = ((Section)this.Section.Connections["ViewArticles"]).Settings;
# D3grade 10/18/2007 8:04 AM
Perfect,

Cheers martjin
# D3grade 10/18/2007 10:39 AM
Hi,

this all works fine, apart from one thing. I'm not sure how big an issue it is, but when i compile and run the site i get the following error
Duplicate class/entity mapping Article 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: NHibernate.DuplicateMappingException: Duplicate class/entity mapping Article

Source Error: 


Line 32: 			Configuration nhConfiguration = this._kernel[typeof(Configuration)] as Configuration;
Line 33:             //has to have the second argument (true) for skipping ordering
Line 34:             nhConfiguration.AddAssembly(assembly, true);
Line 35: 			ISessionFactory newSessionFactory = nhConfiguration.BuildSessionFactory();
Line 36: 			ReplaceSessionFactory(newSessionFactory);
 

Source File: D:\Work\THINK\CMS_DEV02\Source\Core\Service\SessionFactoryHelper.cs    Line: 34 

But, just refreshing the site makes it go away. Should this be ok? or am i doing something wrong?
# martijnb 10/18/2007 2:03 PM (edited 10/18/2007 2:05 PM)
There is already an Article class mapped from the Articles module. If you want to use your own Article class, you should add auto-import="false" attribute to the hibernate-mapping tag to allow multiple classes with the same name.
Note that you have to specify the complete type name in hql queries, including namespaces, after adding auto-import=false.

See also http://www.hibernate.org/hib_docs/nhibernate/html/mapping.html
# D3grade 10/18/2007 2:24 PM
There is only one Article mapping (i modified my Articles module) which is used by both modules, so i can't set anything in the hibernate file as they both use the same one.
# martijnb 10/18/2007 3:59 PM
In that case, one of the two modules shouldn't implement INHibernateModule.
# D3grade 10/18/2007 4:28 PM
Ahhhhhh, nice one, problem solved.

Matt
# D3grade 10/20/2007 12:57 PM
Hi Martijn.

I have done a lot more work on my article modules, and made them into 2 modules. Content module and Content Index module.

The content module is now responsible for saving its own content and the content index module just looks up content with specific categories and lists them.

I now seem to be having a problem that is linked to our previous discussion with regards to the INhibernatModule class.

Basically, both modules need to have access to the Content entity class, however both need to be able to do queries so they both need to implement INhibernateModule.

If my Content Index module does not inherit it, it won't list Content entities untill you go to a Content page first. If you do implement the interface, the index works, but i get the error i mentioned earlier.

What would be the solution to this?

Cheers

Matt
# D3grade 10/21/2007 5:40 PM
Actually, i just found the answer in this thread.

http://www.cuyahoga-project.org/home/forum.aspx?g=posts&t=750