Skip to content

Instantly share code, notes, and snippets.

@StefanHeimberg
Last active October 13, 2015 14:59
Show Gist options
  • Save StefanHeimberg/61169452b48d4e9d4856 to your computer and use it in GitHub Desktop.
Save StefanHeimberg/61169452b48d4e9d4856 to your computer and use it in GitHub Desktop.
JQAssistant Rules für Entities
<jqa:jqassistant-rules xmlns:jqa="http://www.buschmais.com/jqassistant/core/analysis/rules/schema/v1.0">
<!-- http://neo4j.com/developer/cypher/ -->
<constraint id="entity-rules:FieldAccess">
<requiresConcept refId="jpa2:Entity" />
<description>All JPA Entities without Field Access</description>
<cypher><![CDATA[
MATCH
(e:Jpa:Entity)-[:DECLARES]->(m:Method),
(m)-[:ANNOTATED_BY]-()-[:OF_TYPE]->(a:Type)
WHERE
a.fqn =~ "javax.persistence..*"
AND NOT a.fqn =~ "javax.persistence.Pre.*"
AND NOT a.fqn =~ "javax.persistence.Post.*"
OR a.fqn =~ "org.hibernate..*"
OR a.fqn =~ "javax.validation.constraints..*"
RETURN
e.name AS entity,
m.name AS method,
a.name AS annotation
ORDER BY entity, method, annotation ASC
]]></cypher>
</constraint>
<constraint id="entity-rules:JavaSqlTimeTimestampDate">
<requiresConcept refId="jpa2:Entity" />
<description>All JPA Entities with java.sql.* Fields</description>
<cypher><![CDATA[
MATCH
(e:Jpa:Entity)-[:DECLARES]->(f:Field),
(f)-[:OF_TYPE]->(t:Type)
WHERE
t.fqn IN ["java.sql.Timestamp", "java.sql.Time", "java.sql.Date"]
RETURN
e.name AS entity,
f.name AS field,
t.fqn AS type
ORDER BY entity, field, type ASC
]]></cypher>
</constraint>
<group id="default">
<includeConstraint refId="entity-rules:FieldAccess" />
<includeConstraint refId="entity-rules:JavaSqlTimeTimestampDate" />
</group>
</jqa:jqassistant-rules>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment