If i had an additional Spring application extending my Magnolia, which gets some Java Object, which will be used inside my application, how can i save it ???
I already learned to do queries, but i cannot use it yet to put something in or change it. I can only fetch data. into nodes.
where or how do i persist ??
For Info: I have a repository which shall store the special data and i have a nodetype declared for this. As it is now the spring social UserConnection i have the workspace "connections" with nodeType mgnl:userConnection
My JavaObject is a UserConnection, designed near to MgnlUser, so i also add properties, but i don't know yet, what to do with path and uuid.
i don't know yet how to declare it or where to get it.
You can store the data same way as you fetch it. Assuming you are running your spring app through Magnolia filter chain you have MgnlContext setup for given thread and can easily call MgnlContext.getJCRSession("connections") to obtain the session and node same way you do to retrieve your data, to add subnodes or set properties on given node you just call node.addNode("myNewNode") or node.setProperty("myProp", "newValue") on the node and follow that with call to session.save() to persist the session info. But I guess you already know all that.
If you want to get whole object serialised into repo for you by system instead, you can use JackRabbit OCM for this, or even easier - use integration of OCM into Magnolia - http://jira.magnolia-cms.com/browse/MJROCM
. It's already used in Shop module of Magnolia if you are looking for examples on how to work with OCM.
HTH,
Jan
Related
I have embedded Teiid 12.3 in a Spring Boot application. I want to get into the metadata of my VDB in order to generate a diagram using graphviz-java. I assume that if I have a org.teiid.metadata.Table object, I can call getIncomingObjects() to get references to tables that table depends on. I just can't figure out how to navigate from the EmbeddedServer to the Table objects.
I looked into using the administration API available via EmbeddedServer.getAdmin(). From there, I can call getVDBs(), and from there I can navigate down to getModels(), but below that level there is only the model source via getSourceMetadataText(). I also tried subclassing EmbeddedServer to make getVDBRepository() public. I can call getVDBRepository()*.getModels(), but it returns the same Model objects only get me access to the source definition of the models, not the runtime metadata model.
I tried getVDBRepository().getSystemStore() and VDBRepository.getODBCStore(), but those MetadataStores are not for the VDB I have deployed.
I haven't found any examples by Google, Teeid JIRA, Teiid forum, or StackOverflow to help me.
Take look at [1] the getSchema method on Admin API, this method returns the string form of the metadata, however you can grab Schema object for object form. If you do not want that way, Teiid also exposes system catalog using many SYS tables, you can issue SQL queries to grab the metadata of schemas and schema items in a VDB. One for internal access, another is from external access.
BTW one of users created a dependency diagram tool that may be useful if you are trying to do something similar. See [2]. Let me know if you interested in pushing that further.
[1] https://github.com/teiid/teiid/blob/master/runtime/src/main/java/org/teiid/runtime/EmbeddedAdminImpl.java#L544-L557
[2] https://github.com/teiid/metadata-catalog-ui
i have upgraded our application to SWF 2 and have implemented FMPC pattern. majority of our existing flow definitions doesn't have end-state, now using FMPC as described here, you can trigger commit by putting commit=true to your end-state. Example of our flow:
get form object
save details to db (we want to commit here)
fetch the same object with refreshed data
display to view
its currently working with previous SWF and just using Open Session in View pattern. but we imlemented FMPC to avoid any LazyInitializationException. Now what's happening is steps 1-4 is happening except that changes are not committed, so in the view, we don't see any changes. it seems difficult to add end-state at the middle just to commit to DB and also this means we need to add so many end-state, so my question is how to tell (SWF/FMPC) to commit "programmaticaly" without having to add the end-state tag. If you know better approach, please tell also. Thanks!
Spring Web Flows can have inheritance, so you can implement the end-state in your parent flow and then have it as a parent for all your flows.
I resolved my issue. I finally found out that indeed Hibernate is auto-committing all my read-write operations. The problem is when refreshing the object concerned which gave me the impression that there is no read-write done while in fact there is. Doing sessioFactory.refresh(object) instead of plain find() effectively fetched the updated data from the DB. I guess its because the hibernate session is still alive (due to FMPC) that's why doing "find" will retrieve from the hibernate cache while "refresh" means re-reading the data directly from underlying database. Please correct my analysis as necessary.
I'm currently evaluating spring ACL for a web project. The domain model (JPA) of the project consists basically of a hierarchy starting with Company -> Client -> Product and so on. Users (which are members of a company) of the app are only allowed to see Products which belong to their Company.
I don't see any other way than assigning each Company it's own Role (e.g. ROLE_COMPANY_A, ROLE_COMPANY_B, etc), which is persisted more or less hardcoded in the ACL-tables (This is most probably not the best design; open for suggestions...)
While I was able to hook up the Spring ACL with the JPA Layer (Aspect on the various Repository's save()-Methods), I have troubles finding the proper parent ACL Object when inserting a new Entity. To find out to which Company an Entity belongs I must traverse the Object-hierarchy to find the proper Role (i.e. ROLE_COMPANY_A) within the Aspect (which is even worse, since an Aspect should not contain any app-knowledge).
So the question is, if anyone has used spring ACL in a scenario like this one? Since we are not bound to spring ACL, another solution/framework may also be considered. Bascially I really want to avoid the traversal of the object hierarchy to find out the proper Role.
tnx & regards
In a SPA app using breeze, how would I go about combining metadata from multiple sources for related data so that I can use them in 1 manager on the client. For example, I might have the following
Entity Framework Metadata from WebAPI controller (e.g. Account)
Custom Metadata from DTOs (e.g. Invoices)
Data from a third party service with metadata provided from client side metadata (e.g. Invoice transmission result)
In each case the data has related properties so I might want to be able to use Account.Transactions.TransmissionResults
UPDATE
I have tried several ways of getting this to work but to no avail. From Jay's answer, it is not possible at present to update the metadata from the server once it has been retrieved, so if and until that changes (see breeze user voice issue) I am left with one of the following approaches
1 Retrieve metadata from the server from Entity Framework and add metadata on the client to add extra entities. This worked to a degree but I could not add navigation properties from entity types added on the client to entity types retrieved from the server because I cannot add the foreign key association to the entity retrieved from the server, again back to the need to modifying metadata after it has been retrieved.
2 Write the complete metadata by hand, which will work but makes maintainability that much harder and seems wrong to be manually writing mostly the same code that the designer would write.
3 Generate most of the code from Entity Framework as described in the docs and then update it afterwards to add in the custom entities. Again similar issues than with option 2, it seems hacky.
Anyone else tried something similar? Is there something I am missing, which I could be, I've only started with breeze and js.
Thanks
A breeze EntityManager can have metadata from any number of DataService endpoints, and you can manually add metadata (new EntityTypes) on the client at any point. The only current restriction is that once you have metadata from a specific service, you can't change it. ( We are considering reviewing the last restriction).
So the question is, what are you trying to do that you can't right now?
I have a IQueryable function. In that function, I need to store and retrieve data to Session; can you guys point me in the right direction.
I've looked at the HttpSessionStatBase where the session is usually taken from HttpContext.Current but this doesnt seem possible to do in the library. Am I missing something?
Thanks in advance.
I would avoid having a dependency on the static HttpContext. My preferred strategy would be to extract the information from the session in the controller and pass it as parameters (or set as properties) on your data access layer/repository. If you feel that you must use the Session directly, then I would provide it to the DAL/repository in the same manner -- as a property or as a parameter. Note, however, that you are increasing the coupling between your DAL/repository and the controller. This will make it much more difficult to re-use in a non-web setting, i.e., you'd have to create a fake session just to interact with the DAL/repository if you ever needed to work with it from a windows service or console app, for example.