From d79f46b3733b44ca62a1f92c576d68ddb28ec368 Mon Sep 17 00:00:00 2001 From: Godin Date: Fri, 17 Dec 2010 00:05:04 +0000 Subject: * 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 --- .../java/org/sonar/api/profiles/RulesProfile.java | 28 +++++++++++++++++++--- .../main/java/org/sonar/api/rules/ActiveRule.java | 19 +++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) (limited to 'sonar-plugin-api') 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 projects = new ArrayList(); - @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() @@ -193,6 +196,24 @@ public class RulesProfile implements Cloneable { return this; } + /** + * 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 */ @@ -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(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 @@ -89,6 +89,24 @@ public class ActiveRule implements Cloneable { return id; } + /** + * 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 */ @@ -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(CollectionUtils.collect(getActiveRuleParams(), new Transformer() { public Object transform(Object input) { -- cgit v1.2.3