Trying to fetch related entity on JHipster and being tricked by Jackson? - fetch

I am trying to build an item -> details page on my application involving entities EcmOrder ->> EcmOrderItem -> Product as described below:
JDL model fragment:
By using side by side techniques, I extended the repository, service and resource classes on back end. The extended EcmOrder repository has a new "find" method which eagerly fetches the associated EcmOrderItem and Product data:
#Repository
public interface EcmOrderRepositoryEx extends EcmOrderRepository {
#Query("select ecmOrder "
+ "from EcmOrder ecmOrder "
+ "join fetch ecmOrder.ordOits ecmOrderItem "
+ "left outer join fetch ecmOrderItem.oitPro product where ecmOrder.id =:id")
Optional<EcmOrder> findOneWithEagerRelationships(#Param("id") Long id);
}
On the front end, I extended various elements and changed the html template to accommodate the additional data that now comes embedded into the incoming order data.
The page has the following aspect:
The problem is that the repository query gets all the data, including the EcmOrder, all EcmOrderItems and Product for each EcmOrderItem but json serialized data that arrives in the browser does not include the Product data, thus leaving the "Oit Pro" column blank, as evidenced by the browser snapshot below:
So my question has two parts:
I guess this is probably related to #JsonIgnoreProperties used by JHipster on the entities java classes but tampering with that is the correct way to go?
Is there a way to solve this problem while avoiding changes to JHipster generated files, i.e., only adding my code?

Related

How to get query parameters value from deep link while dynamic link created using AppInvitation class using Firebase?

In my app, I am sending invitation to people to join my app. I am using AppInvitation IntentBuilder Class to create Intent. After these steps, one URL-link gets generated that we can send to invitees.
I have written below code to generated that link and start the activity to send the link. I am able to send invites and able to successfully launch the app by clicking the dynamiclinks. Both the dynamically and manually created ones.
IDictionary<string, string> values = new Dictionary<string, string>();
values.Add("utm_campaign", "Health");
values.Add("utm_medium", "GoIbibo");
values.Add("ad", "1");
values.Add("credit", "50");
values.Add("utm_source", "Yahoo");
values.Add("afl", "https://www.facebook.com");
var intentbuidl = new AppInviteInvitation.IntentBuilder(MainActivity.mainActivity.GetString(Resource.String.invitation_title))
.SetMessage(MainActivity.mainActivity.GetString(Resource.String.invitation_message))
.SetDeepLink(Android.Net.Uri.Parse(MainActivity.mainActivity.GetString(Resource.String.invitation_deep_link)))
.SetAdditionalReferralParameters(values)
.Build();
MainActivity.mainActivity.StartActivityForResult(Intent.CreateChooser(intentbuidl, "Install"),0);
Generated link: https://aku4q.app.goo.gl/i/619426442529-4a4105fd-33ea-4b0f-bf07-6f4063eef8f8
So my question is, when do invitees open the app using this link? Can we be able to get these additional parameters which I have set using IDictionary from the above generated link?
To my knowledge, no. This is one of the limitations of Firebase deep linking — you can't pass custom parameters and need to use the URL string for everything.
You could check out Branch.io (full disclosure: I'm on the Branch team) for an alternative approach that does allow custom parameters.

Mail Merge Feature for a CRM web-app made in asp.NET

We're working on a web based CRM for my company in ASP.net. I frequently have to send newsletters to all of my customers, and it becomes tedious to manually copy all of their addresses. What I would like is a feature to send one mail to all of my customers, taking their addresses from our contacts database, similar to a mail merge.
My developer said that he can do this for Emails, but not for physical mail. His reasoning behind this is that he can write a script that sends the mails to all customers one by one, but he can only give one single print command, which would only be able to print the current contents of the page. Therefore, he would not be able to print the individual letters for all of the customers.
Does anyone have ideas on how this would be possible? E.g. printing the page in such a way that each letter would be printed on a seperate page, or another way to automatically print all of the letters (with the mailmerged fields)?
Any help will be appreciated. If you require more details, please tell me.
A webpage is not the right solution to physically print letters. What you need to produce is a report that would generate a PDF file. This report will generate a PDF document with a different customer address on each page. Try using Microsoft Reporting Services, it is included in SQL Server. Crystal Reports is also a popular reporting solution too.
Also, you will have a hard time printing the stylized contents of your nice looking e-mail in the reporting solutions mentioned above. Consider using the report only as the cover letter of your mail piece.
One possible solution is to use 3rd party library for creation of individual letters for your customers. Docentric Toolkit is .NET tool that solves exactly your problem. We are using it for creating individual letters for customers and they all are merged in one file so that printing is done only once. Users can even create or change template documents.
Next you would have to create a template document in MS Word where you would include fixed content and placeholders for variable content which would be filled in at runtime with customer information.
After processing the data in .NET application you merge the data with the template document (see code snippet below). Your final document will be one file with letters for your customers, each on its own page. This file can then be sent to the printer with one print command.
I am attaching a code snippet of a Main method of the sample console application. The project has references to Entity Framework and Docentric’s dlls and uses entity model of Northwind database.
As you can see, it is really easy to prepare the data and merge it with template document. Solution is suitable for ASP.NET and MVC applications because you don’t need Microsoft Office installed on the server.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Docentric.Word;
namespace DisplayCustomers
{
class Program
{
static void Main(string[] args)
{
// first we read customers - in the example we select only customers
// from USA and Canada and order them by country and customer name
List<Customers> customerList = new List<Customers>();
using (var db = new NORTHWNDEntities())
{
customerList = db.Customers
.OrderBy(o => o.Country)
.ThenBy(o => o.CompanyName)
.Where(w => w.Country == "USA" || w.Country == "Canada")
.ToList();
}
// next we merge customers data with the template and generate final document;
string templateDoc = #"C:\Test\Templates\CustomerLetter1_templ.docx";
string outputDoc = #"C:\Test\FinishedLetters\CustomerLetters1.docx";
DocumentGenerator dg = new DocumentGenerator(customerList);
DocumentGenerationResult result = dg.GenerateDocument(templateDoc, outputDoc);
}
}
}

How do you have managed a status of contents in Symfony2

How do you have created a status of blog, micropost and etc?
I simply have created a status which each application entity has a status code of boolean.
False is private, true is public.
It is a multi-user environment in fosuserbundle.
It was created without any problems until now.
However, I wanted to be able to set user, group, and other status set in a multi-user environment.
(like a linux permissions, 744, etc...)
So, I think that it might create a bundle that manages the status.
The comment bundle that I have created is relation each application bundle by the ID of the string.
{{ render(controller('MyCommentBundle:Default:embed', {
'id' : 'for_example_micropost_' ~ micropost.id, // => relation id
'name' : micropost.owner.username,
'request': app.request
})) }}
However, it can not use when viewing list of application contents.
(Because the query occurs in one by one)
For example, either simply relationship by creating a column for each application.
Status Entity
blog_id
micropost_id
picture_id
etc...
But I think it inconvenient.
It require care of additional column when generated for each new application.
And I feel it is not a smart also.
For example, do so in the list part. Conditions of the string if possible in DQL.
public function find_all($owner, $limit, $offset)
{
$q = $this->getEntityManager()->createQuery('
SELECT p FROM MyMicropostBundle:Post p
LEFT JOIN MyStatusBundle s
With s.relation_id = :prefix + p.id
WHERE s.code > 744
')
->setParameter("prefix", 'for_example_micropost_')
->setParameter("owner", $owner)
->setMaxResults($limit)
->setFirstResult($offset);
return $q->getResult();
}
Etc., various I think, but I do not know the best way.
How do you have created a status?
Do you know status bundle already?
Or do you know bundle may be relevant to me.
If there is an optimal way and ideas, please tell me.
StatusBundle process:
It check a access user first.
It check a status code and groups and owner associated with the contents.
It compare a status code, groups and owner of the content to a access user.
I think it is possible to create (relation) bundle within a single page in my skills.
However, problem is how to relations at such a list display page that query to get the contents of the large number.
For example, I get the data of the last 10 blog posts.
I get the last 10 of public status posts if a access user is not the owner.
It is easy if Post entity has a status.
However, I think how to check a status, groups and owner if a status of a post has been registered in the status entity of other bundle.
I think that how to handle the status bundle while I get the data of the contents of the large number.

StructureGroup Details using the Content Delivery/Broker API

I am trying to get all the structure groups published in a given publication using the PublicationID. I am expecting to get the structure groups with StructureGroupCriteria by passing the Root Structure Group TCM ID but getting page ids (I am expecting SGs).
Now I am trying to loop through the list and get details of each structuregroup. I did not find any API (.net) to get these details and also the API is returning only Pages.
What I have done and working so far using StructureGroupCriteria, returns list of Page IDs instead of SG IDs
PublicationCriteria pubCriteria = new PublicationCriteria(pubID);
// Root StructureGroup TCM ID -- tcm:45-3-4
StructureGroupCriteria sgCriteria = new StructureGroupCriteria("tcm:45-3-4", true);
Criteria allSGsInPub = CriteriaFactory.And(pubCriteria, sgCriteria);
Query allSGs = new Query(allSGsInPub);
string[] sgInfo = allSGs.ExecuteQuery();
Response.Write("Total : " + sgInfo.Length);
foreach (string sgid in sgInfo ) {
// HOW DO I get the Structure Group Details here
//TCMURI sgURI = new TCMURI(sgid);
}
Q # 1 : How to get the all the structuregroups and individual structure group details? (May be something simple, I am not able to find right API).
Q # 2 : How can I get all the structuregroups using ItemTypeCriteria sgCriteria = new ItemTypeCriteria(4); // 4 is SG Item Type .
When I tried this option, the query worked successfully but no results returned. Is this the expected behavior and should we always use StructureGroupCriteria instead of ItemTypeCriteria?
The reason for this approach, I want to avoid using the Root StructureGroup ID which is required with the above code. But at the moment, none of the approaches returning StructureGroup information and I always get Page Information.
Tridion Version: 2011 SP1, .net API.
Note: When I publish I am checking the publish SG info checkbox and published successfully. On Broker DB side, I can see the information on the taxnonomy table as well.
I was playing with Odata service and accidentally I found that I can get all my structure group information from Odata web service.
/cd_webservice/odata.svc/StructureGroups?$filter=PublicationId%20eq%2045
Also, the results are returning child structure groups with a depth parameter.
Just to clarify , using Broker API it is not feasible to get the structure groups (my original question). However, the workaround solution is to use OData Service to get the Structure Groups.
I don't think you will get Structure Groups returned by the Query object.
According to the documentation, when you publish Structure Group information the Structure Group hierarchy is published to the Content Delivery side where it is stored as a taxonomy.
Have you tried using the Taxonomy APIs to get the information you need?

Programicatlly visit (all) ASP.Net page(s) in a website?

In the Security model for out ASP.Net website (.Net 3.5) we store the page name:
page.GetType().Name
as the primary key in a database table to be able to lookup if a user has access to a certain page. The first time a page is visited this record is created automatically in the database.
We have exported these database statements to insert scripts, but each time a new page gets created we have to update the scripts, not a huge issue, but I would like to find an automated way to do this.
I created an attribute that I tagged a few pages with and then wrote a small process to get all the objects that have this attribute, through the reflection create an instance and insert the record using the same code to for page records mentioned above:
IEnumerable<Type> viewsecurityPages = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsDefined(typeof(ViewSecurityAttribute),false));
foreach (Type t in viewsecurityPages)
{
object obj = Activator.CreateInstance(t, false);
//clip..(This code just checks if the record already exists in the DB)
if (feature == null)
{
Attribute attb = Attribute.GetCustomAttribute(t, typeof(ViewSecurityAttribute));
if (attb != null)
{
CreateSecurableFeatureForPage((Page)obj, uow, attb.ToString());
}
}
}
The issue is that page.GetType().Name when the page goes through the actual page cycle process is something like this:
search_accounts_aspx
but when I used the activator method above it returns:
Accounts
So the records don't match the in the security table. Is there anyway to programtically "visit" a webpage so that it goes through the actual page lifecycle and I would get back the correct value from the Name parameter?
Any help/reference will be greatly appreciated.
Interesting problem...
Of course there's a (too obvious?) way to programmatically visit the page... use System.Net.HttpWebRequest. Of course, that requires the URI and not just a handle to the object. This is a "how do we get there from here?" problem.
My suggestions would be to simply create another attribute (or use that same one) which stores the identifier you need. Then it will be the same either way you access it, right?
Alternatively... why not just use a 3rd party web spider/crawler to crawl your site and hit all the pages? There are several free options. Or am I missing something?

Resources