Changeset 7312


Ignore:
Timestamp:
Mar 21, 2017, 9:44:03 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2065: Exception when trying to delete a data file type that is referenced from item subtype

The item subtype should now be displayed in the trashcan under the "Items using" section.

Location:
trunk/src/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/common-queries.xml

    r7298 r7312  
    24012401  </query>
    24022402 
     2403  <query id="GET_ITEMSUBTYPES_FOR_DATAFILETYPE" type="HQL">
     2404    <sql>
     2405      SELECT {1}
     2406      FROM ItemSubtypeFileTypeData sft
     2407      WHERE sft.dataFileType = :dataFileType
     2408    </sql>
     2409    <description>
     2410      A Hibernate query that gets item subtype file types for a specific
     2411      data file type.
     2412    </description>
     2413  </query>
     2414 
     2415 
    24032416  <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL">
    24042417    <sql>
  • trunk/src/core/net/sf/basedb/core/DataFileType.java

    r7016 r7312  
    456456      count = HibernateUtil.loadData(Long.class, query);
    457457    }
     458    if (count == 0)
     459    {
     460      query = HibernateUtil.getPredefinedQuery(session,
     461        "GET_ITEMSUBTYPES_FOR_DATAFILETYPE", "count(*)");
     462      /*
     463        SELECT {1}
     464        FROM ItemSubtypeFileTypeData sft
     465        WHERE sft.dataFileType = :dataFileType
     466      */
     467      query.setEntity("dataFileType", this.getData());
     468      count = HibernateUtil.loadData(Long.class, query);
     469    }
    458470    return count > 0 || super.isUsed();
    459471  }
     
    462474    <ul>
    463475    <li>{@link FileSetMember}:s using this file type
    464     <li>{@link PlatformFileType}:s using this file type
     476    <li>{@link Platform}:s using this file type
     477    <li>{@link ItemSubtype}:s using this file type
    465478    </ul>
    466479  */
     
    480493    addUsingItems(using, Item.FILESETMEMBER, query);
    481494    query = HibernateUtil.getPredefinedQuery(session,
    482       "GET_PLATFORMFILETYPE_FOR_DATAFILETYPE", "pft.id");
     495      "GET_PLATFORMFILETYPE_FOR_DATAFILETYPE", "pft.platform.id");
    483496      /*
    484497        SELECT {1}
     
    487500      */
    488501    query.setEntity("dataFileType", this.getData());
    489     addUsingItems(using, Item.PLATFORMFILETYPE, query);
     502    addUsingItems(using, Item.PLATFORM, query);
     503    query = HibernateUtil.getPredefinedQuery(session,
     504      "GET_ITEMSUBTYPES_FOR_DATAFILETYPE", "sft.itemSubtype.id");
     505      /*
     506        SELECT {1}
     507        FROM ItemSubtypeFileTypeData sft
     508        WHERE sft.dataFileType = :dataFileType
     509      */
     510    query.setEntity("dataFileType", this.getData());
     511    addUsingItems(using, Item.ITEMSUBTYPE, query);
    490512    return using;
    491513  }
Note: See TracChangeset for help on using the changeset viewer.