Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRUNK-4917 - Add Creatable and Changeable interfaces #2245

Merged
merged 4 commits into from Nov 10, 2017

Conversation

wluyima
Copy link
Member

@wluyima wluyima commented Sep 22, 2017

Description of what I changed

I added the new Creatable and Changeable interfaces, deprecated the changedBy and dateChanged setters and getters in the relevant super classes

This pull request is just a partial commit so that I can get some feedback from other devs before I can go ahead to do the major refactoring of updating the domain objects to extend BaseChangeableOpenmrsData or BaseChangeableOpenmrsMetadata

Issue I worked on

see https://issues.openmrs.org/browse/TRUNK-4917

*/
public void setDateChanged(Date dateChanged);

public interface Auditable extends Creatable, Changeable {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we actually get rid of this interface? Or should we keep it around?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we can scan core code and popular modules and ensure nobody is referencing it, I would keep it around for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely it's referenced in core, but in the follow up commit I was going to replace its usage. I wasn't going to remove it in this version, we would mark it as deprecated now and eventually remove it may be 2 versions later.

* @since 2.2
*/
public abstract class BaseChangeableOpenmrsData extends BaseOpenmrsData {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these overrides so that these setters/getters don't appear deprecated as an effect from the superclass since eventually the methods will still exist on this class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public interface OpenmrsData extends OpenmrsObject, Auditable, Voidable {}
Which more methods will be added in OpenmrsData interface?
Or OpenmrsData interface will implement the methods of Creatable interface which contain getCreator, getDateCreated methods and Changeable interface contain getChangedBy, getDateChanged methods?

Copy link
Member Author

@wluyima wluyima Nov 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenmrsData for now will stay the way it is, in future it will implement Creatable instead of Auditable because Data should be immutable by default.

@wluyima
Copy link
Member Author

wluyima commented Sep 22, 2017

@djazayeri and @bmamlin does this seem in line with option D from this design call?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 56.502% when pulling abb327c on wluyima:TRUNK-4917-2 into 42b4339 on openmrs:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 56.608% when pulling fa57c91 on wluyima:TRUNK-4917-2 into 42b4339 on openmrs:master.

Copy link
Member

@bmamlin bmamlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I think the summary for TRUNK-4917 needs to be updated to reflect what you've done here (i.e., "Changeable" vs. "Mutable"). Also, would like to know how big of an effect this has on core and popular modules.

* @see OpenmrsData
* @see OpenmrsMetadata
* @see MutableOpenmrsData
* @see MutableOpenmrsMetadata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do MutableOpenmrsData and MutableOpenmrsMetadata classes exist outside of this PR? Or should these be references Changeable, BaseChangeableOpenmrsData, and BaseChangeableOpenmrsMetadata classes?

Copy link
Member Author

@wluyima wluyima Oct 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I had them and removed them and should have updated these javadocs

*/
public void setDateChanged(Date dateChanged);

public interface Auditable extends Creatable, Changeable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we can scan core code and popular modules and ensure nobody is referencing it, I would keep it around for now.

* @since 2.2
*/
public abstract class BaseChangeableOpenmrsData extends BaseOpenmrsData {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense.

*/
@Override
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}

/**
* @see org.openmrs.Auditable#getChangedBy()
* @deprecated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume @deprecated in javadoc would ideally include "as of version x.y".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will add it

@wluyima
Copy link
Member Author

wluyima commented Oct 5, 2017

In core we are going to change subclasses of BaseOpenmrsData to extend BaseChangeableOpenmrsData instead, likewise subclasses of BaseOpenmrsMetadata will extend BaseChangeableOpenmrsMetadata. The same will apply for all modules, although it doesn't have to be immediate but will have to once we remove the deprecated code.

…escriptions for the @SInCE annotations

TRUNK-4917 - Removed non-existent type references
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 56.535% when pulling cc711fe on wluyima:TRUNK-4917-2 into 42b4339 on openmrs:master.

@openmrs openmrs deleted a comment Oct 19, 2017
@openmrs openmrs deleted a comment Oct 19, 2017
@openmrs openmrs deleted a comment Oct 19, 2017
@wluyima
Copy link
Member Author

wluyima commented Oct 23, 2017

@bmamlin I did address the review comments, I think we can merge this along with the change of all subclasses of BaseOpenmrsData and BaseOpenmrsMetadata to extend the new base classes.

@wluyima
Copy link
Member Author

wluyima commented Nov 6, 2017

@dkayiwa , @rkorytkowski do you mind merging this PR after you review it? I need to do the next step of changing domain objects to extend BaseChangeableOpenmrsData or BaseChangeableOpenmrsMetadata instead.

@dkayiwa
Copy link
Member

dkayiwa commented Nov 7, 2017

@wluyima will it take you much time to squash these commits into one? I find it easier to review one commit than multiple, especially when they are followup commits to address earlier review comments.

@wluyima
Copy link
Member Author

wluyima commented Nov 7, 2017

@dkayiwa you shouldn't be looking at individual commits, the PR shows them as one

@wluyima
Copy link
Member Author

wluyima commented Nov 7, 2017

Aren't you viewing all the changes as one in Files changed tab on the PR?

@wluyima
Copy link
Member Author

wluyima commented Nov 9, 2017

Still waiting on you @dkayiwa

*/
@Override
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}

/**
* @see org.openmrs.Auditable#getChangedBy()
* @see org.openmrs.OpenmrsMetadata#getChangedBy()
* @deprecated as of version 2.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our convention has been to include what they should alternatively use. https://wiki.openmrs.org/display/docs/Java+Conventions#JavaConventions-Deprecation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods are actually going away with no replacement, I think I just have to add more details as to why it was necessary to remove the method.

Copy link
Member Author

@wluyima wluyima Nov 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And to mention that we introduced a new interface that one would need to implement in case they want to have a mutable class

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the method javadocs have the @see the superclass where information as to why it's deprecated is included

@dkayiwa dkayiwa merged commit 0d8bf59 into openmrs:master Nov 10, 2017
@wluyima wluyima deleted the TRUNK-4917-2 branch November 14, 2017 21:38
jtatia pushed a commit to jtatia/openmrs-core that referenced this pull request Aug 20, 2018
* TRUNK-4917 - Add Creatable and Changeable interfaces

* TRUNK-4917 - Renamed usaged of Mutable to Changeable

* TRUNK-4917 - Removed unnecessary deprecation comments

* TRUNK-4917 - Removed non-existent type references and added missing descriptions for the @SInCE annotations

TRUNK-4917 - Removed non-existent type references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants