diff options
author | Godin <mandrikov@gmail.com> | 2010-12-17 00:05:04 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-12-17 00:05:04 +0000 |
commit | d79f46b3733b44ca62a1f92c576d68ddb28ec368 (patch) | |
tree | 4c901a6ea4545069cad85549913dbf273b5f870b /sonar-plugin-api | |
parent | dcbf1fc1630fa311fdbbe883e4e286d2fa74bd76 (diff) | |
download | sonarqube-d79f46b3733b44ca62a1f92c576d68ddb28ec368.tar.gz sonarqube-d79f46b3733b44ca62a1f92c576d68ddb28ec368.zip |
* SONAR-2048: Add an option to define parent in quality profile settings
* SONAR-1722: Provide a simple inheritance mechanism on Quality Profiles
** current implementation is some kind of synchronization between profiles
** only one level of inheritance supported, this constraint exists on UI side and not handled on Java side
** inherited rule can't be modified
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java | 28 | ||||
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java | 19 |
2 files changed, 44 insertions, 3 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java index 292d6c9d23f..06fe96c829c 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java @@ -82,9 +82,12 @@ public class RulesProfile implements Cloneable { @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY) private List<ResourceModel> projects = new ArrayList<ResourceModel>(); - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "parent_id", updatable = true, nullable = true) - private RulesProfile parentProfile; + // @ManyToOne(fetch = FetchType.LAZY) + // @JoinColumn(name = "parent_id", updatable = true, nullable = true) + // private RulesProfile parentProfile; + + @Column(name = "parent_id", updatable = true, nullable = true) + private Integer parentId; /** * @deprecated use the factory method create() @@ -194,6 +197,24 @@ public class RulesProfile implements Cloneable { } /** + * For internal use only. + * + * @since 2.5 + */ + public Integer getParentId() { + return parentId; + } + + /** + * For internal use only. + * + * @since 2.5 + */ + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + /** * @return the list of alerts defined in the profile */ public List<Alert> getAlerts() { @@ -311,6 +332,7 @@ public class RulesProfile implements Cloneable { RulesProfile clone = RulesProfile.create(getName(), getLanguage()); clone.setDefaultProfile(getDefaultProfile()); clone.setProvided(getProvided()); + clone.setParentId(getParentId()); if (CollectionUtils.isNotEmpty(getActiveRules())) { clone.setActiveRules(new ArrayList<ActiveRule>(CollectionUtils.collect(getActiveRules(), new Transformer() { public Object transform(Object input) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java index f6f8b0fef30..a53c3f01c79 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java @@ -90,6 +90,24 @@ public class ActiveRule implements Cloneable { } /** + * For internal use only. + * + * @since 2.5 + */ + public boolean isInherited() { + return inherited == null ? false : inherited; + } + + /** + * For internal use only. + * + * @since 2.5 + */ + public void setInherited(boolean inherited) { + this.inherited = inherited; + } + + /** * @deprecated visibility should be decreased to protected or package */ @Deprecated @@ -243,6 +261,7 @@ public class ActiveRule implements Cloneable { @Override public Object clone() { ActiveRule clone = new ActiveRule(getRulesProfile(), getRule(), getSeverity()); + clone.setInherited(isInherited()); if (CollectionUtils.isNotEmpty(getActiveRuleParams())) { clone.setActiveRuleParams(new ArrayList<ActiveRuleParam>(CollectionUtils.collect(getActiveRuleParams(), new Transformer() { public Object transform(Object input) { |