Changeset 1284


Ignore:
Timestamp:
Feb 8, 2011, 9:45:46 AM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #292: Check/create annotation types, etc. required by reggie

This should now work with the items that we need so far for the personal information registration wizard.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/.classpath

    r1283 r1284  
    33  <classpathentry kind="src" path="src"/>
    44  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    5   <classpathentry kind="lib" path="lib/compile/BASE2Core.jar"/>
     5  <classpathentry kind="lib" path="lib/compile/BASE2Core.jar" sourcepath="/trunk/src/core"/>
    66  <classpathentry kind="lib" path="lib/compile/BASE2Webclient.jar"/>
    77  <classpathentry kind="lib" path="lib/compile/servlet-api.jar"/>
    88  <classpathentry kind="lib" path="lib/reggie/json_simple-1.1.jar"/>
     9  <classpathentry kind="lib" path="lib/compile/BASE2WSClient.jar"/>
    910  <classpathentry kind="output" path="bin"/>
    1011</classpath>
  • extensions/net.sf.basedb.reggie/trunk/META-INF/servlets.xml

    r1283 r1284  
    55    <servlet-class>net.sf.basedb.reggie.servlet.AjaxServlet</servlet-class>
    66  </servlet>
     7  <servlet>
     8    <servlet-name>Install</servlet-name>
     9    <servlet-class>net.sf.basedb.reggie.servlet.InstallServlet</servlet-class>
     10  </servlet>
    711
    812</servlets>
  • extensions/net.sf.basedb.reggie/trunk/README

    r1282 r1284  
    2020    installation. Otherwise, just wait a bit and the automatic installation will
    2121    find and install the new extension.
    22  5. Done.
     22 5. Log in as a user with Administrator priviliges. Go to the Extensions -> Reggie
     23    menu. Select the 'Verify/install required annotation types and other items'
     24    wizard and create the required items.
     25 6. Done.
    2326 
    2427Reggie appears as a menu entry in the Extensions menu. All operations
  • extensions/net.sf.basedb.reggie/trunk/build.xml

    r1283 r1284  
    129129  <target
    130130    name="checkjar"
    131     description="Checks that the BASE2Core.jar and BASE2Webclient.jar exists."
     131    description="Checks that the BASE2Core.jar, BASE2Webclient.jar and BASE2WSClient.jar exists."
    132132    >
    133133    <available classname="net.sf.basedb.core.Application"
     
    135135    <available classname="net.sf.basedb.clients.web.Base"
    136136      classpathref="classpath" property="base2web" />
     137    <available classname="net.sf.basedb.info.BioAssaySetInfo"
     138      classpathref="classpath" property="base2webservice" />
     139
    137140    <fail unless="base2core" message="Can't find BASE2Core.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
    138141    <fail unless="base2web" message="Can't find BASE2Webclient.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
     142    <fail unless="base2webservice" message="Can't find BASE2WSClient.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
    139143    <echo>Found BASE2Core.jar and BASE2Webclient.jar.</echo>
    140144  </target>
     
    142146  <target
    143147    name="download-lib"
    144     description="Download BASE2Core.jar, BASE2Webclient.jar and BASE2CorePlugins.jar."
     148    description="Download BASE2Core.jar, BASE2Webclient.jar and BASE2WSClient.jar."
    145149    >
    146150    <echo>
     
    153157    <download-lib file="BASE2Core.jar" />
    154158    <download-lib file="BASE2Webclient.jar" />
     159    <download-lib file="BASE2WSClient.jar" />
    155160  </target>
    156161 
  • extensions/net.sf.basedb.reggie/trunk/resources/index.jsp

    r1283 r1284  
    44  import="net.sf.basedb.core.Application"
    55  import="net.sf.basedb.core.User"
     6  import="net.sf.basedb.core.Role"
     7  import="net.sf.basedb.core.Group"
    68  import="net.sf.basedb.core.DbControl"
    79  import="net.sf.basedb.core.SessionControl"
     10  import="net.sf.basedb.core.SystemItems"
     11  import="net.sf.basedb.core.ItemQuery"
     12  import="net.sf.basedb.core.query.Expressions"
     13  import="net.sf.basedb.core.query.Hql"
     14  import="net.sf.basedb.core.query.Restrictions"
    815  import="net.sf.basedb.clients.web.Base"
    916  import="net.sf.basedb.clients.web.util.HTML"
    1017  import="net.sf.basedb.util.Values"
     18  import="java.util.List"
    1119%>
    1220<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    2129  dc = sc.newDbControl();
    2230  final User user = User.getById(dc, sc.getLoggedInUserId());
     31  boolean isAdmin = false;
     32  boolean isPatientCurator = false;
     33  try
     34  {
     35    Role admin = Role.getById(dc, SystemItems.getId(Role.ADMINISTRATOR));
     36    isAdmin = sc.isMemberOf(admin);
     37  }
     38  catch (RuntimeException ex)
     39  {}
     40  try
     41  {
     42    ItemQuery<Group> query = Group.getQuery();
     43    query.restrict(Restrictions.eq(Hql.property("name"), Expressions.string("PatientCurator")));
     44    List<Group> result = query.list(dc);
     45    if (result.size() == 1)
     46    {
     47      isPatientCurator = sc.isMemberOf(result.get(0));
     48    }
     49  }
     50  catch (RuntimeException ex)
     51  {}
    2352%>
    2453<base:page type="default" >
     
    3867    <div class="boxedbottom">
    3968      <ul>
    40       <li><a href="persinfo.jsp?ID=<%=ID%>">Personal information registration</a>
     69      <%
     70      if (isAdmin)
     71      {
     72        %>
     73        <li><a href="install.jsp?ID=<%=ID%>">Verify/install required annotation types and other items</a>
     74        <%
     75      }
     76      if (isPatientCurator || isAdmin)
     77      {
     78        %>
     79        <li><a href="persinfo.jsp?ID=<%=ID%>">Personal information registration</a>
     80        <%
     81      }
     82      %>
    4183      </ul>
    4284   
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java

    r1283 r1284  
    77import net.sf.basedb.core.AnnotationType;
    88import net.sf.basedb.core.DbControl;
     9import net.sf.basedb.core.Group;
    910import net.sf.basedb.core.Include;
    1011import net.sf.basedb.core.InvalidDataException;
     
    2526
    2627  /**
    27     The name of the "Personal number" annotation type, used
    28     to store 12-digit personal number for biosources. The
     28    The name of the "PersonalNumber" annotation type, used
     29    to store 12-digit personal number for biosources (Patient). The
    2930    number should be unique and is stored as a string.
    3031  */
    31   public static final String PERSONAL_NUMBER = "PersonalNumber";
     32  public static final String ANNOTATION_PERSONAL_NUMBER = "PersonalNumber";
    3233 
    33   public static final String FAMILY_NAME = "FamilyName";
     34  /**
     35    The name of the "FamilyName" annotation type, used
     36    to store the family name for biosources (Patient). It is a
     37    string annotation type.
     38  */
     39  public static final String ANNOTATION_FAMILY_NAME = "FamilyName";
    3440 
    35   public static final String ALL_FIRST_NAMES = "AllFirstNames";
     41  /**
     42    The name of the "AllFirstNames" annotation type, used
     43    to store the first names for biosources (Patient). It is a
     44    string annotation type.
     45  */
     46  public static final String ANNOTATION_ALL_FIRST_NAMES = "AllFirstNames";
    3647 
    37   public static final String GENDER = "Gender";
     48  /**
     49    The name of the "GENDER" annotation type, used
     50    to store the gender of biosources (Patient). It is an
     51    enumerated string annotation type with two options: F and M.
     52  */
     53  public static final String ANNOTATION_GENDER = "Gender";
     54
     55  /**
     56    The name of the "DateOfBirth" annotation type, used
     57    to store the date of birth for biosources (Patient). It is a
     58    date annotation type.
     59  */
     60  public static final String ANNOTATION_DATE_OF_BIRTH = "DateOfBirth";
    3861 
    39   public static final String DATE_OF_BIRTH = "DateOfBirth";
     62  /**
     63    The name of the "Laterality" annotation type, used
     64    for samples (Case). It is an enumerated string annotation
     65    type with two options: LEFT and RIGHT.
     66  */
     67  public static final String ANNOTATION_LATERALITY = "Laterality";
    4068 
    41   public static final String LATERALITY = "Laterality";
     69  /**
     70    The name of the "PatientCurator" group. Members of this group
     71    are allowed to use the personal information registration wizard.
     72  */
     73  public static final String GROUP_PATIENT_CURATOR = "PatientCurator";
    4274 
     75  /**
     76    List all groups with the given name.
     77  */
     78  public static List<Group> listGroups(DbControl dc, String name)
     79  {
     80    ItemQuery<Group> query = Group.getQuery();
     81    query.restrict(Restrictions.eq(Hql.property("name"), Expressions.parameter("name", name, Type.STRING)));
     82    query.include(Include.ALL);
     83    return query.list(dc);
     84  }
    4385 
    44   public static AnnotationType findAnnotationType(DbControl dc, Item itemType, String name)
     86  /**
     87    Find a single group with the given name. If exactly one is found it
     88    is returned, otherwise null is returned or an exception is thrown
     89    depending on the exceptionIfNotFound parameter.
     90  */
     91  public static Group findGroup(DbControl dc, String name, boolean exceptionIfNotFound)
     92  {
     93    List<Group> result = listGroups(dc, name);
     94    Group g = null;
     95    if (result.size() == 0)
     96    {
     97      if (exceptionIfNotFound) throw new ItemNotFoundException("Group["+name+"]");
     98    }
     99    else if (result.size() > 1)
     100    {
     101      if (exceptionIfNotFound) throw new InvalidDataException("Found > 1 Group["+name+"]");
     102    }
     103    else
     104    {
     105      g = result.get(0);
     106    }
     107    return g;
     108 
     109  }
     110
     111  /**
     112    List all annotation types with the given name.
     113  */
     114  public static List<AnnotationType> listAnnotationTypes(DbControl dc, Item itemType, String name)
    45115  {
    46116    ItemQuery<AnnotationType> query = AnnotationType.getQuery(itemType);
    47117    query.restrict(Restrictions.eq(Hql.property("name"), Expressions.parameter("name", name, Type.STRING)));
    48118    query.include(Include.ALL);
    49     List<AnnotationType> result = query.list(dc);
     119    return query.list(dc);
     120  }
     121 
     122  /**
     123    Find a single annotation type with the given name. If exactly one is found it
     124    is returned, otherwise null is returned or an exception is thrown
     125    depending on the exceptionIfNotFound parameter.
     126  */
     127  public static AnnotationType findAnnotationType(DbControl dc, Item itemType, String name, boolean exceptionIfNotFound)
     128  {
     129    List<AnnotationType> result = listAnnotationTypes(dc, itemType, name);
     130    AnnotationType at = null;
    50131    if (result.size() == 0)
    51132    {
    52       throw new ItemNotFoundException("AnnotationType["+name+"]");
     133      if (exceptionIfNotFound) throw new ItemNotFoundException("AnnotationType["+name+"]");
    53134    }
    54135    else if (result.size() > 1)
    55136    {
    56       throw new InvalidDataException("Found > 1 AnnotationType["+name+"]");
     137      if (exceptionIfNotFound) throw new InvalidDataException("Found > 1 AnnotationType["+name+"]");
    57138    }
    58     return result.get(0);
     139    else
     140    {
     141      at = result.get(0);
     142    }
     143    return at;
    59144  }
    60145 
     146  /**
     147    Get a (single) annotation value from an item.
     148  */
    61149  public static Object getAnnotationValue(Annotatable item, AnnotationType at)
    62150  {
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/AjaxServlet.java

    r1283 r1284  
    6565      {
    6666        dc = sc.newDbControl();
    67         AnnotationType pnrType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.PERSONAL_NUMBER);
     67        AnnotationType pnrType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_PERSONAL_NUMBER, true);
    6868       
    6969        String pnr = req.getParameter("personalNumber");
     
    8383        if (result.size() == 1)
    8484        {
    85           AnnotationType familyNameType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.FAMILY_NAME);
    86           AnnotationType allFirstNamesType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ALL_FIRST_NAMES);
    87           AnnotationType genderType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.GENDER);
    88           AnnotationType dateOfBirthType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.DATE_OF_BIRTH);
    89           AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.LATERALITY);
     85          AnnotationType familyNameType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_FAMILY_NAME, true);
     86          AnnotationType allFirstNamesType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_ALL_FIRST_NAMES, true);
     87          AnnotationType genderType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_GENDER, true);
     88          AnnotationType dateOfBirthType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_DATE_OF_BIRTH, true);
     89          AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true);
    9090          DateFormatter df = new DateFormatter("yyyy-MM-dd");
    9191          BioSource bs = result.get(0);
Note: See TracChangeset for help on using the changeset viewer.