All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.jqassistant-rules.jpa2.xml Maven / Gradle / Ivy

<jqa:jqassistant-rules xmlns:jqa="http://www.buschmais.com/jqassistant/core/analysis/rules/schema/v1.0">

    <concept id="jpa2:Entity">
        <description>Labels all types annotated with @javax.persistence.Entity with "Jpa" and "Entity".</description>
        <cypher><![CDATA[
            MATCH
              (t:Type)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(a:Type)
            WHERE
              a.fqn="javax.persistence.Entity"
            SET
              t:Jpa:Entity
            RETURN
              t AS JpaEntity
        ]]></cypher>
    </concept>

    <concept id="jpa2:Embeddable">
        <description>Labels all types annotated with @javax.persistence.Embeddable with "Jpa" and "Embeddable".</description>
        <cypher><![CDATA[
            MATCH
              (t:Type)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(a:Type)
            WHERE
              a.fqn="javax.persistence.Embeddable"
            SET
              t:Jpa:Embeddable
            RETURN
              t AS JpaEmbeddable
        ]]></cypher>
    </concept>

    <concept id="jpa2:Embedded">
        <description>Labels all fields or methods annotated with @javax.persistence.Embedded with "Jpa" and "Embedded".</description>
        <cypher><![CDATA[
            MATCH
              (t:Type)-[:DECLARES]->(member),
              (member)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(a:Type)
            WHERE
              (member:Field or member:Method)
              and a.fqn="javax.persistence.Embedded"
            SET
              member:Jpa:Embedded
            RETURN
              member AS JpaEmbedded
        ]]></cypher>
    </concept>

    <concept id="jpa2:EmbeddedId">
        <description>Labels all fields or methods annotated with @javax.persistence.EmbeddedId with "Jpa" and "Embedded".</description>
        <cypher><![CDATA[
            MATCH
              (t:Type)-[:DECLARES]->(member),
              (member)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(a:Type)
            WHERE
              (member:Field or member:Method)
              and a.fqn="javax.persistence.EmbeddedId"
            SET
              member:Jpa:EmbeddedId
            RETURN
              member AS EmbeddedId
        ]]></cypher>
    </concept>

    <concept id="jpa2:NamedQuery">
        <requiresConcept refId="jpa2:Entity"/>
        <description>Creates a node labeled with "Jpa" and "NamedQuery" for each @NamedQuery defined for an entity.
            Furthermore a relation DEFINES is created between the entity and the named query.
        </description>
        <cypher><![CDATA[
            MATCH
              (entity:Jpa:Entity),
              (entity)-[:ANNOTATED_BY]->(namedQueries:Annotation)-[:OF_TYPE]-(:Type{fqn:'javax.persistence.NamedQueries'}),
              (namedQueries)-[:HAS]->(:Value:Array)-[:CONTAINS]->(namedQuery),
              (namedQuery)-[:OF_TYPE]->(:Type{fqn:'javax.persistence.NamedQuery'}),
              (namedQuery)-[:HAS]->(nameAttribute:Value{name:'name'}),
              (namedQuery)-[:HAS]->(queryAttribute:Value{name:'query'})
            MERGE
              (entity)-[:DEFINES]->(n:Jpa:NamedQuery {name:nameAttribute.value, query:queryAttribute.value})
            RETURN
              entity as Entity, n.name as Name, n.query as Query
            UNION ALL
            MATCH
              (entity)-[:ANNOTATED_BY]->(namedQuery:Annotation),
              (namedQuery)-[:OF_TYPE]->(:Type{fqn:'javax.persistence.NamedQuery'}),
              (namedQuery)-[:HAS]->(nameAttribute:Value{name:'name'}),
              (namedQuery)-[:HAS]->(queryAttribute:Value{name:'query'})
            MERGE
              (entity)-[:DEFINES]->(n:Jpa:NamedQuery {name:nameAttribute.value, query:queryAttribute.value})
            RETURN
              entity as Entity, n.name as Name, n.query as Query
        ]]></cypher>
    </concept>

    <constraint id="jpa2:ValidationModeMustBeExplicitlySpecified">
        <description>The validation mode of all persistence units must be explicitly specified and either set to CALLBACK or NONE.</description>
        <cypher><![CDATA[
            MATCH
              (pu:PersistenceUnit)
            WHERE
              not has(pu.validationMode)
              OR NOT (
                pu.validationMode='CALLBACK'
                OR pu.validationMode='NONE'
              )
            RETURN
              pu AS PersistenceUnit
        ]]></cypher>
    </constraint>

</jqa:jqassistant-rules>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy