How to add custom properties/tags to an existing commit in JaVers? - javers

We currently use javers for tracking the history of several entities (Study, Survey, Data Set, Instrument). All these objects belong to the entity Project. Once a project is released - by saving it with a versionNumber property - I would like to tag the latest commit of the other entities with this versionNumber for instance by adding a custom commit property. This would be similar to git tagging.
Does anyone know how to achieve this?

I don't think there currently is a Javers API method to support this.
The only way I can think of doing what you need, is to get all available GlobalIDs and update the database directly with a script, setting the desired commit properties.
The DB schemas are not very complex so it's probably not very hard.
You would need to add each commit property in jv_commit_property and then modify each commit with the desired property.

Related

Deploying solution from Dev to Production fails because column with same schema name data type was changed. Object dependencies won't get deleted

So the column in question was a lookup column, which i deleted in the unmanaged solution, and mistakenly created a new column with the same name. Dynamics by default will use the same auto-generated schema name based on the display name. So when I go to import the unmanaged solution in my dev environment into the production environment as managed, obviously it throws an error because of the mismatched of data types per column schema name.
Error returned by Azure Pipeline
So I did the sensible next thing, and went to delete this column in my dev environment. But oh no! There are object dependencies which prevent me from deleting it, okay I look at which objects depend on this column, it is a form, i remove the column from the form, go to delete and oh no again! There is still a dependency on the form I just deleted the column from.
So what do I do? I can't change the column schema name, I can't change the data type back to the data type that's currently in the managed solution. Is this when I open up a microsoft support ticket? Hopefully someone here has some insight. Thanks!
The attribute can be associated with a custom control. Try removing this custom control using the classic form designer. It should be visible on one of the field property tabs.
If the attribute cannot be found anywhere on the form using the classic or modern form designer, try this:
Create a solution with this form only. Export the solution as unmanaged. Extract the customization.xml from the zip. Edit the xml and remove all references to your attribute. Paste the customization.xml into the zip and import and publish the solution.
The only way to delete a managed component is to upgrade the solution. In your case, you can delete the field and dependency in solution and apply the upgrade to target environment. Please noticed that all data in this field would get deleted when you apply the upgrade. You may check this link for more detail

add attributes to user entity in jhipster

I want to add some attributes to the user entity, when I googled about it, I found a similar question :
How to modify existing entity generated with jhipster?
when I followed the steps in this post, I couldn't find the file user.json anywhere as #Roberto montioned
1) Edit the json file representing your entity (add/remove field, the syntax is pretty easy, check in the end of the file if is required any change to the general entity properties like 'fieldsContainOneToMany'...), you'll find it in:
<jhipster_root_folder>/.jhipster/entityName.json
How can I solve this ?
I think the best solution is a compromise between the two solutions offered by #Pedro and #alcuvi (who references to the JHipster Documentation):
First, create an "ExtendedUser" entity with the additional fields (don't forget to use git, you will have to undo this/delete the entity). A one-to-one relationship to "User" is not necessary.
After that, you can copy many parts from "ExtendedUser" to the other parts of the JHipster Application:
Liquibase changelog columns (also add them to users.csv)
ExtendedUser.java → User.java and UserDTO.java
extendedUser-dialog.* → register.html/.controller.js and settings.html/.controller.js
Adapt AccountResource.java and UserService.java (and UnitTests if you use them). This step is mostly done by using getters and setters copied in the step before. JHipster Documentation (https://jhipster.github.io/tips/022_tip_registering_user_with_additional_information.html) might be helpful here.
Delete the "ExtendedUser" Entity (using git, or manually, see also: How to delete an entity after creating it using jhipster?)
The *advantages* are:
Using JHipster code generation capabilities
No additional entity (which comes with new DB tables and many files)
I hope this information will help other developers in the future!
The User entity is the entity used by JHipster to manage all user management stuff, like email, passwords, etc., so you won't find a User.json file, since that is an automatically generated entity. Those .json files are only created when you run yo jhipster:entity <entityName>.
In order to add/remove fields to the User entity, you'll have to do it manually, that means editing User.java, creating a liquibase changeset and modify all related files in the UI as needed.
The official documentation of jhipster (version 4) have an entry about this.
https://jhipster.github.io/tips/022_tip_registering_user_with_additional_information.html
In summary...
Its manual solution.
The proposed solution is to create an entity with the fields you want to add to user and linked to it with a one to one relationship.
Alternatively
If you create a ExtendedUser with new fields with JDL-Studio the jhipsterimport-jdl command is going to create "extendedUser" option on entity menu where you can set values for those fields and linked to the user you want.
I thinks is not the best solution...
What about inheritance? Just extend built-in User class with new fields. For example, public class ExtendedUser extends User. And replace User class with ExtendedUser in code. Update dto, service, etc. Also you can use class casting where it's required. What thoughts?

How to trigger commit programmaticaly on Spring Webflow 2 with Flow Managed Persistence Context

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.

Using Entity Framework with Oracle and Mapping Inheritance - Table-per-Type. Trigger updated Id is not being set in subclass table

I am using Oracle with Entity Framework. The database ids are generated using triggers and sequences.
I want to set up Table-per-Type inheritance, as described here. I've set the "CourseId" to be StoreGeneratedPattern of "Identity".
Everything seems to be fine, except when I insert a row. The table representing the base class (in the walkthrough linked above, the Course table) gets a generated ID as expected.
However the table representing the inherited class (in the walkthrough linked above, the OnlineCourse table) has a row inserted with the CourseId set to zero. This violates the foreign key constraint.
I assume it's something to do with the sequence of inserts. I imagine it should work like:
Insert the Course row
Retrieve the newly created CourseId value
Insert the OnlineCourse, using the new CourseId
However, this isn't working because it's just using the default value of the CourseId (zero) to insert into OnlineCourse.
Any ideas how to fix this?
Since #Campinho hasn't written up his suggestion as an answer, I will do it.
This article has some background on a bug in StoreGeneratedPattern in VS2010.
One of very important features in ORM tools is an ability to get data auto-generated by a database during the entity persistence back to your application. The Entity framework supports this feature by setting StoreGeneratedPattern in the configuration of persisted property. The StoreGeneratedPattern setting is available in both SSDL (Store schema definition language) and CSDL (Conceptual schema definition language) parts of the EDMX file. CSDL configuration allows you defining the reloading behavior in the Model-first approach but SSDL part is responsible for generating correct SQL commands which will persist the entity and reload auto-generated properties. Unfortunately for a long time this was the source of all problems.
The feature was very hard to use because of the annoying bug in the Entity designer. When we set the property in the designer, the value was saved only in CSDL part but not in SSDL part of the EDMX file and the feature didn't work until we opened the EDMX file as XML and manually modified SSDL part. This solved the problem but only until we updated our model from the database. The update always deleted whole SSDL part including our manual change so we had to do it again. Any incremental development of our models become a big pain. The workaround was using mapped stored procedures for inserting and updating entities and mapping result sets (returning auto-generated data) from these stored procedures back to the entity. Finally this bug is solved in Visual Studio 2010 SP1 and we can use StoreGeneratedPattern without any problems because the value is correctly set in both CSDL and SSDL parts and it is not overwritten during updating from the database.
If you have this problem install KB2561001.
I installed the hotfix and changed the StoreGeneratedPattern to "None" then back to "Identity" for the relevant Ids. I could clearly see the SSDL section had been updated to indicate the new setting.
Then everything just worked! I'm not sure what's going to be in the patch from Oracle that they think will fix the problem.
I filed a service request with Oracle and it turns out this is a bug in their provider.
BUG 13724992 - EF: ENTITY NOT UPDATED AFTER SAVECHANGES USING STOREGENERATEDPATTERN
A fix for this bug will be released in an upcoming patchset. However, which patchset in will be included in and when that patchset will be released is currently unknown. I will let you know as soon as this fix will be released.

Tracking Changes Object Changes

I wanted to get your opinions on the easiest way to track changes that users make when they do CRUD events. I am working on a system where the users are less interested on permissions, but really want to have a sophisticated log of what changes a user made. I am using ASP.NET MVC 3, EF, and NLog.
Any advice is greatly appreciated :)
Steve
I use a convention based approach. Each entity has an associated audit entity which includes all properties from the base entity plus information on the change, including whether it was successful or not. I override the SaveChanges method on the DB context. For each entity being changed it creates an audit entity from it holding the new values. It attempts to save the changes, then uses a separate, auditing context to save each of the audited entities with the results of the save operation. I use an injected utility in the data context to get access to the current user (via HttpContext.Current for web, via the Environment.User for non-web) when constructing the audit entities.
I blogged about an earlier version of this for LINQ to SQL at http://farm-fresh-code.blogspot.com/2009/05/auditing-inserts-and-updates-using-linq.html. You should be able to get the basic idea from that.

Resources