I am developing one HR web Application and it is connected to alfresco 5.0 repository, in my custom web application i need one Advanced search feature.
Here want to get all Employee documents who have joined from xyz date to current date.
I am thinking for writing custom web-script.
but not getting will it be a proper approach or not.
Can you please suggest me that Either CMIS will be a better approach or custom web-script will be better?
If CMIS, then please provide sample code or steps.
Thanks in Advance
CMIS has everything you need for this. If you are using CMIS elsewhere in your application, use CMIS for this. If you aren't using CMIS then write a web script.
If you choose to go the CMIS route, here is an example from the custom content types tutorial showing how you use CMIS to do searches with date ranges against dates in a property defined in an aspect:
queryString = "select d.cmis:objectId, w.sc:published from sc:whitepaper as d join sc:webable as w on d.cmis:objectId = w.cmis:objectId " +
"where w.sc:published > TIMESTAMP '2006-01-01T00:00:00.000-05:00' " +
" and w.sc:published < TIMESTAMP '2007-06-02T00:00:00.000-05:00'";
In this example, the "sc:webable" aspect has a date time property called "sc:published" and I'm getting back the white papers published between 1/1/2006 and 6/2/2007. In your case that publish date would be the employee hire date.
Depending on how many employees there are, you may want to page over the result set. To understand how to do that see here.
Related
I am running a following AEM Query SQL2 on CRXDE and it is successfully returning me nodes as per following given screenshot.
But I need data like column wise (jcr properties) like SQL table. Can anyone help me if it is possible.
You can't do this with CRXDE. It shows only the path of the most outer node, even if the query has multiple columns. This is especially limiting, if your query uses joins.
In your case I would recommend the Query Builder. It has a totally different syntax, but the JSON or XML result contains all data you need.
I don't know other tools. As AEM developer I usually write a quick & dirty servlet, and let it run on my local instance (with production content)
Query Builder Debugger
http://localhost:4502/libs/cq/search/content/querydebug.html
Example Query
path=/content/we-retail/language-masters/en/experience
property=sling:resourceType
property.value=weretail/components/content/image
p.hits=full
p.nodedepth=2
Resulting JSON Query
http://localhost:4502/bin/querybuilder.json?p.hits=full&p.nodedepth=2&path=%2fcontent%2fwe-retail%2flanguage-masters%2fen%2fexperience&property=sling%3aresourceType&property.value=weretail%2fcomponents%2fcontent%2fimage
http://localhost:4502/bin/querybuilder.json?p.hits=full&p.nodedepth=2&path=%2fcontent%2fwe-retail%2flanguage-masters%2fen%2fexperience&property=sling%3aresourceType&property.value=weretail%2fcomponents%2fcontent%2fimage
Documentation
https://docs.adobe.com/content/help/en/experience-manager-64/developing/platform/query-builder/querybuilder-api.html
In your case especially see: Refining What Is Returned
You will find much more with Google, as the Query Builder is pretty old in AEM/CQ.
I Want to retrieve All document content from alfresco repository. So can anyone help me that how can i traverse the repository using CMIS. And while traversing i also want to separate the documents based on its type.
At this moment i am able to get any one document by specifying the path. but now my requirement is to traverse whole repository and get all the documents.
So can any one help me with this.
Also suggest me that "Traversal of all folders and later separate by specific type" will be the good approach OR "Search specific type of document using CMIS query" will be the good approach.
Thanks in Advance.
Yagami's answer is a good start, but there are a few things to add.
First, do not do "select *" unless you actually need every single property the repository has. That is a potential performance problem. Only ask for what you need.
Second, one of your comments talks about segmenting results by type. In CMIS, a type is kind of like a SQL table. So in your case, you would do three different queries using each of your three custom types as a different type in the from clause:
select * from test:mainContract;
select * from test:subContract;
select * from test:royaltyStatement;
Finally, unless you have just a handful of documents in your repository, you are almost certainly going to want to use a paged result set. Otherwise, you will only get back the maximum number of results the server is configured to return. That may not be large enough to get the entire set.
For an example showing paging the result set, see Apache CMIS: Paging query result
To perform an action like this (getting all the document content) you need to follow this steps
Step 1 : Create a saver Class
What i mean with sever class, it will hold two information (for me it's the most valuable informations) the two of them most be character varying
1 - The document ID
2 - The document Name
Step 2 : Get all the document
To get all the document we have to use a query
String query;
query = "SELECT * FROM cmis:document ";
You will get all the document that you have in your repository.
You can add some condition to make your research more easier like in this example :
query = "SELECT * FROM cmis:document WHERE IN_FOLDER('" + folderId + "')";
In this example you will get document of a particular folder.
ItemIterable<QueryResult> resultList = session.query(query, false);
and finally
for (QueryResult qr : resultList) {
String idDocument = qr.getPropertyByQueryName("cmis:objectId").getFirstValue().toString();
String name = qr.getPropertyByQueryName("cmis:name").getFirstValue().toString();
Document doc = (Document) session.getObject(idDocument);// this is how you can get document with add that's mean no need of path
}
You can read more about query in CMIS query.
Step 3 : Save every time the information in the saver class
I think it's clear that you have to save every time you use the loop (in step 2) in an occurence of saver class.
I hope that helped you.
I have a website (bootleg/css) I put together. I am currently implementing user registration but I am having troubles determining the best way to go about the following:
I have users that will be entering their teammates, and themselves into a tournament (via a form). That's the easy part. Once the users have input their info, I'd like the webpage to populate with the registered team in a designated area. The structure as so:
(Registration form)
TEAM NAME
Member 1
Member 2
Member 3
Member 4
I want it to take TEAM NAME and display it in a specific section of a webpage for those registered. Like so:
(Displayed as so)
REGISTERED TEAMS:
Slayers
Dominatrix
Evolution
I am most familiar with css and html, but I am willing to work with php as long as it can be injected into the current site. I have a MySQL server setup and can edit it further. I've done a LOT on the design side, but not too much on the scripting side until recently so go easy on me.
You can do this by simply using PHP and MySQL.As you said,you are familiar with MySQL,I would give you the outline to do this.
Make a table for the registered users,Insert data to MySQL Database using INSERT Query in MySQL.
INSERT INTO Table_name (id,member_name,member_age,...) VALUE ('','$name','$age',...)
You can select all the values using SELECT Query from Database Table,and echo it on HTML part,where you want to show the result.
SELECT * FROM Table_name
I have the following scenario:
My website db has a system table called "Companies", which includes an id field, companyName field, and companyImageUrl field.
How do I set up an umbraco document type for adding entries to this table ?
Maybe I shouldn't use a custom table at all ?
Thanks.
As far as I know, Umbraco doesn't support what you want to do out of the box (mapping a document type to a table that isn't part of the umbraco core).
One approach that might work is to create an action handler that syncs a Company doc type to your table when creating a node of that type.
It's a bit of a hack though. I've found that I've very rarely needed to create custom tables. What exactly are you trying to do with it? My guess is that you don't really need it and would be better off working with a doc type instead. Umbraco provides a variety of ways to get and act upon doc types from within custom C# code (check out the umbraco.NodeFactory namespace). You'll also get the added benefit of being able to easily interact with these nodes from XSLT/Razor.
Simple problem. I use the Entity framework to map an SQL Server database to objects. The EF is then used to fill a Dynamic Data Site. There are 50+ tables and layout isn't really important. Allowing the users to use it for quick data entry while keeping the amount of code as low as possible is.
Basically, I have four work-hours to find a solution to filter some of the tables on the first letter of one (or more) of the fields. (One filter per field.) When I have one, I have another 4 hours to implement it. Any time I spend more on this will not be compensated. :-(
I have full control over the code, the database structure and whatever else. However, I am limited to .NET 3.5/Visual Studio 2008 and am not allowed to include MVC. I'm also not allowed to add more libraries. Can't upgrade to .NET 4.0 either. So, how can I add such filters in a minimum number of hours?
Simple answer : add filters the way the Dynamic Data samples add filters, using user controls and FilterRepeaters and designating your custom filters in Metadata . See the DynamicData/Filterss directory for examples.
For example, in metadata
[FilterUIHint("LastNameSearch")]
public object LastName { get; set; }
and a user control called LastNameSearch.ascx.
See this link on MSDN