Changeset 2157


Ignore:
Timestamp:
Dec 5, 2013, 2:44:10 PM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #528: Restrict access to some registation wizards

Defined several new roles for Reggie. The installation wizard should install them automatically.

The index page will now start with all links disabled and ask about the permissions for the current user. Once the permissions has been retreived the links will be enabled if the user has the requested permission.

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

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/index.jsp

    r2134 r2157  
    3636  boolean isAdmin = user.getId() == SystemItems.getId(User.ROOT);
    3737  boolean isPatientCurator = false;
    38   boolean hasCreateSamplePermission = sc.hasPermission(Permission.CREATE, Item.SAMPLE);
    39   boolean hasCreateExtractPermission = sc.hasPermission(Permission.CREATE, Item.EXTRACT);
    40   boolean hasCreateBioPlatePermission = sc.hasPermission(Permission.CREATE, Item.BIOPLATE);
    4138  if (!isAdmin)
    4239  {
     
    6966 
    7067  var debug = false;
    71  
    72   function caseSummary()
    73   {
    74     var frm = document.forms['reggie'];
    75    
    76     var caseName = frm.caseName.value;
    77     if (!caseName)
    78     {
    79       alert('Please enter a 7-digit case id');
    80       return;
    81     }
    82     location.href = 'reports/case_summary.jsp?ID=<%=ID%>&caseName='+encodeURIComponent(caseName);
    83   }
    84  
    85   var currentCount;
    86   function startCounting(what)
    87   {
    88     var url;
    89     currentCount = what;
    90     if (what == 'specimen')
    91     {
    92       url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=CountSpecimenTubes';
    93     }
    94     else if (what == 'histology-lists')
    95     {
    96       url = 'Histology.servlet?ID=<%=ID%>&cmd=CountHistologyWorkLists';
    97     }
    98     else if (what == 'paraffin-blocks')
    99     {
    100       url = 'Histology.servlet?ID=<%=ID%>&cmd=CountParaffinBlocks';
    101     }
    102     else if (what == 'paraffin-blocks-without-heglass')
    103     {
    104       url = 'Histology.servlet?ID=<%=ID%>&cmd=CountParaffinBlocksWithoutHeGlass';
    105     }
    106     else if (what == 'unscored-heglass')
    107     {
    108       url = 'Histology.servlet?ID=<%=ID%>&cmd=CountUnscoredHeGlass';
    109     }
    110     else if (what == 'lysate')
    111     {
    112       url = 'Extraction.servlet?ID=<%=ID%>&cmd=CountUnprocessedLysates';
    113     }
    114     else if (what == 'rnaqc')
    115     {
    116       url = 'RnaQc.servlet?ID=<%=ID%>&cmd=CountRnaExtractsWithoutQc';
    117     }
    118     else if (what == 'caliper-plates')
    119     {
    120       url = 'RnaQc.servlet?ID=<%=ID%>&cmd=CountActiveRnaQcBioPlates';
    121     }
    122     else if (what == 'rna-without-mrna')
    123     {
    124       url = 'MRna.servlet?ID=<%=ID%>&cmd=CountRnaWithoutMRna';
    125     }
    126     else if (what == 'mrna-plates')
    127     {
    128       url = 'MRna.servlet?ID=<%=ID%>&cmd=CountUnprocessedPlates&plateType=MRNA';
    129     }
    130     else if (what == 'cdna-plates')
    131     {
    132       url = 'MRna.servlet?ID=<%=ID%>&cmd=CountUnprocessedPlates&plateType=CDNA';
    133     }
    134     else if (what == 'cdna-plates-for-barcoding')
    135     {
    136       url = 'LibPrep.servlet?ID=<%=ID%>&cmd=CountCDNAPlatesForBarcoding';
    137     }
    138     else if (what == 'lib-plates')
    139     {
    140       url = 'LibPrep.servlet?ID=<%=ID%>&cmd=CountLibPlatesForLibPrep';
    141     }
    142     else if (what == 'lib-plates-for-pooling')
    143     {
    144       url = 'Pool.servlet?ID=<%=ID%>&cmd=CountLibraryPlatesForPooling';
    145     }
    146     else if (what == 'unregistered-pools')
    147     {
    148       url = 'Pool.servlet?ID=<%=ID%>&cmd=CountUnprocessedPools';
    149     }
    150     else if (what == 'unused-pools')
    151     {
    152       url = 'FlowCell.servlet?ID=<%=ID%>&cmd=CountUnusedPools';
    153     }
    154     else if (what == 'unregistered-flow-cells')
    155     {
    156       url = 'FlowCell.servlet?ID=<%=ID%>&cmd=CountUnprocessedFlowCells';
    157     }
    158    
    159     if (url)
    160     {
    161       var request = Main.getAjaxRequest();
    162       request.open("GET", url, false);
    163       Ajax.setReadyStateHandler(request, onCounted, onCounted);
    164       request.send(null);
    165     }
    166   }
    167  
    168   function onCounted(request)
    169   {
    170     if (debug) Main.debug(currentCount +': ' + Main.encodeTags(request.responseText));
     68  var myPermissions = {};
     69 
     70  function init()
     71  {
     72    // Get permission information
     73    var url = 'Install.servlet?ID=<%=ID%>&cmd=GetPermissions';
     74    var request = Main.getAjaxRequest();
     75    request.open("GET", url, false);
     76    Ajax.setReadyStateHandler(request, onPermissions, onPermissions);
     77    request.send(null);
     78  }
     79 
     80  // Callback when permission information is ready
     81  function onPermissions(request)
     82  {
     83    if (debug) Main.debug(Main.encodeTags(request.responseText));
    17184    var response;
    17285    var error = false;
     
    18497    }
    18598   
     99    if (error)
     100    {
     101      alert(error);
     102      return;
     103    }
     104   
     105    myPermissions = response.permissions;
     106    var isAdmin = myPermissions['Administrator'] == 1;
     107   
     108    // Enable links based on the permission
     109    var wizards = document.getElementsByClassName('require-permission');
     110    // NOTE! Loop backwards since changing the classname
     111    // of an element so that 'require-permission' no longer is included
     112    // removes the element from the 'wizards' list
     113    for (var wizardNo = wizards.length-1; wizardNo >= 0; wizardNo--)
     114    {
     115      var wizard = wizards[wizardNo];
     116      var role = wizard.getAttribute('data-role');
     117      if (myPermissions[role] == 1 || isAdmin)
     118      {
     119        wizard.className = 'link';
     120        wizard.addEventListener('click', goWizard);
     121      }
     122      else
     123      {
     124        wizard.title = 'You do not have permission to user this wizard';
     125      }
     126    }
     127   
     128    // Start couting queued items
     129    startCounting('specimen');
     130  }
     131 
     132  function caseSummary()
     133  {
     134    var frm = document.forms['reggie'];
     135   
     136    var caseName = frm.caseName.value;
     137    if (!caseName)
     138    {
     139      alert('Please enter a 7-digit case id');
     140      return;
     141    }
     142    location.href = 'reports/case_summary.jsp?ID=<%=ID%>&caseName='+encodeURIComponent(caseName);
     143  }
     144 
     145  var currentCount;
     146  function startCounting(what)
     147  {
     148    var url;
     149    currentCount = what;
     150    if (what == 'specimen')
     151    {
     152      url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=CountSpecimenTubes';
     153    }
     154    else if (what == 'histology-lists')
     155    {
     156      url = 'Histology.servlet?ID=<%=ID%>&cmd=CountHistologyWorkLists';
     157    }
     158    else if (what == 'paraffin-blocks')
     159    {
     160      url = 'Histology.servlet?ID=<%=ID%>&cmd=CountParaffinBlocks';
     161    }
     162    else if (what == 'paraffin-blocks-without-heglass')
     163    {
     164      url = 'Histology.servlet?ID=<%=ID%>&cmd=CountParaffinBlocksWithoutHeGlass';
     165    }
     166    else if (what == 'unscored-heglass')
     167    {
     168      url = 'Histology.servlet?ID=<%=ID%>&cmd=CountUnscoredHeGlass';
     169    }
     170    else if (what == 'lysate')
     171    {
     172      url = 'Extraction.servlet?ID=<%=ID%>&cmd=CountUnprocessedLysates';
     173    }
     174    else if (what == 'rnaqc')
     175    {
     176      url = 'RnaQc.servlet?ID=<%=ID%>&cmd=CountRnaExtractsWithoutQc';
     177    }
     178    else if (what == 'caliper-plates')
     179    {
     180      url = 'RnaQc.servlet?ID=<%=ID%>&cmd=CountActiveRnaQcBioPlates';
     181    }
     182    else if (what == 'rna-without-mrna')
     183    {
     184      url = 'MRna.servlet?ID=<%=ID%>&cmd=CountRnaWithoutMRna';
     185    }
     186    else if (what == 'mrna-plates')
     187    {
     188      url = 'MRna.servlet?ID=<%=ID%>&cmd=CountUnprocessedPlates&plateType=MRNA';
     189    }
     190    else if (what == 'cdna-plates')
     191    {
     192      url = 'MRna.servlet?ID=<%=ID%>&cmd=CountUnprocessedPlates&plateType=CDNA';
     193    }
     194    else if (what == 'cdna-plates-for-barcoding')
     195    {
     196      url = 'LibPrep.servlet?ID=<%=ID%>&cmd=CountCDNAPlatesForBarcoding';
     197    }
     198    else if (what == 'lib-plates')
     199    {
     200      url = 'LibPrep.servlet?ID=<%=ID%>&cmd=CountLibPlatesForLibPrep';
     201    }
     202    else if (what == 'lib-plates-for-pooling')
     203    {
     204      url = 'Pool.servlet?ID=<%=ID%>&cmd=CountLibraryPlatesForPooling';
     205    }
     206    else if (what == 'unregistered-pools')
     207    {
     208      url = 'Pool.servlet?ID=<%=ID%>&cmd=CountUnprocessedPools';
     209    }
     210    else if (what == 'unused-pools')
     211    {
     212      url = 'FlowCell.servlet?ID=<%=ID%>&cmd=CountUnusedPools';
     213    }
     214    else if (what == 'unregistered-flow-cells')
     215    {
     216      url = 'FlowCell.servlet?ID=<%=ID%>&cmd=CountUnprocessedFlowCells';
     217    }
     218   
     219    if (url)
     220    {
     221      var request = Main.getAjaxRequest();
     222      request.open("GET", url, false);
     223      Ajax.setReadyStateHandler(request, onCounted, onCounted);
     224      request.send(null);
     225    }
     226  }
     227 
     228  function onCounted(request)
     229  {
     230    if (debug) Main.debug(currentCount +': ' + Main.encodeTags(request.responseText));
     231    var response;
     232    var error = false;
     233    try
     234    {
     235      response = JSON.parse(request.responseText);
     236      if (response.status != 'ok')
     237      {
     238        error = response.message || response.stacktrace || 'Unexpected error';
     239      }
     240    }
     241    catch (ex)
     242    {
     243      error = ex;
     244    }
     245   
    186246    if (currentCount == 'specimen')
    187247    {
     
    323383    {
    324384      div.innerHTML = '(' + count + ')';
     385    }
     386  }
     387 
     388  function goWizard(event)
     389  {
     390    var role = event.currentTarget.getAttribute('data-role');
     391    if (myPermissions[role] == 1)
     392    {
     393      var link = event.currentTarget.getAttribute('data-link');
     394      location.href = link;
     395    }
     396    else
     397    {
     398      alert('You do not have permission to use this wizard!');
    325399    }
    326400  }
     
    386460  font-style: italic;
    387461}
     462
     463.require-permission
     464{
     465  color: #999999;
     466  font-style: italic;
     467}
     468
    388469</style>
    389470</base:head>
    390 <base:body onload="startCounting('specimen')">
     471<base:body onload="init()">
    391472
    392473  <p:path><p:pathelement title="Reggie" /></p:path>
     
    398479     
    399480        <h3>Sample processing wizards</h3>
    400         <dl class="leftborder rightborder bottomborder">
    401         <%
    402         if (hasCreateSamplePermission)
    403         {
    404           %>
    405           <dt>
    406             <base:icon image="<%=home+"/images/specimen.png" %>" />
    407             <a href="sampleproc/specimentube.jsp?ID=<%=ID%>">Specimen tube registration</a>
    408           </dt>
    409           <dd>
    410             <ul>
    411             <li>Register new specimen tubes.
    412             <li>Update existing specimen tubes.
    413             </ul>
    414           </dd>
    415           <%
    416         }
    417         if (hasCreateSamplePermission && hasCreateExtractPermission)
    418         {
    419           %>
    420           <dt>
    421             <base:icon image="<%=home+"/images/partition.png" %>" />
    422             <a href="sampleproc/partitionform.jsp?ID=<%=ID%>">Partition wizard</a>
    423           </dt>
    424           <dd>
    425             <ul>
    426             <li>Register new partitions of existing specimens <span class="counter" id="count.specimen" title="Counting..."><img src="images/loading-small.gif"></span>
    427             </ul>
    428           </dd>
    429           <%
    430         }
    431         if (hasCreateSamplePermission && hasCreateBioPlatePermission)
    432         {
    433           %>
    434           <dt>
    435             <base:icon image="<%=home+"/images/microscope.png" %>" />
    436             Histology wizards
    437           </dt>
    438           <dd>
    439             <ul>
    440             <li><a href="sampleproc/histology_protocol.jsp?ID=<%=ID%>">Lab tracking protocol for FFPE/HE</a> <span class="counter" id="count.histology-lists" title="Counting..."><img src="images/loading-small.gif"></span>
    441             <li><a href="sampleproc/histology_block.jsp?ID=<%=ID%>">Register paraffin blocks</a> <span class="counter" id="count.paraffin-blocks" title="Counting..."><img src="images/loading-small.gif"></span>
    442             <li><a href="sampleproc/histology_glass.jsp?ID=<%=ID%>">Register HE glass</a> <span class="counter" id="count.paraffin-blocks-without-heglass" title="Counting..."><img src="images/loading-small.gif"></span>
    443             <li><a href="sampleproc/histology_score.jsp?ID=<%=ID%>">Score HE glass</a> <span class="counter" id="count.unscored-heglass" title="Counting..."><img src="images/loading-small.gif"></span>
    444             </ul>
    445           </dd>
    446           <%
    447         }
    448         if (hasCreateExtractPermission)
    449         {
    450           %>
    451           <dt>
    452             <base:icon image="<%=home+"/images/extraction.png" %>" />
    453             DNA/RNA extraction wizards
    454           </dt>
    455           <dd>
    456             <ul>
    457             <li><a href="sampleproc/allprep_protocol.jsp?ID=<%=ID%>">Lab tracking protocol for Allprep isolation</a> <span class="counter" id="count.lysate.1" title="Counting..."><img src="images/loading-small.gif"></span>
    458             <li><a href="sampleproc/extraction_registration.jsp?ID=<%=ID%>">DNA/RNA/FlowThrough registration</a> <span class="counter" id="count.lysate.2" title="Counting..."><img src="images/loading-small.gif"></span>
    459             </ul>
    460           </dd>
    461           <dt>
    462             <base:icon image="<%=home+"/images/rnaqc.png" %>" />
    463             RNA quality control wizards
    464           </dt>
    465           <dd>
    466             <ul>
    467             <li><a href="sampleproc/rnaqc_aliquot.jsp?ID=<%=ID%>">Create aliquots on Bioanalyzer/Caliper plates</a> <span class="counter" id="count.rnaqc" title="Counting..."><img src="images/loading-small.gif"></span>
    468             <li><a href="sampleproc/rnaqc_plate_export.jsp?ID=<%=ID%>">Export Caliper sample names and run parameters</a> <span class="counter" id="count.caliper-plates.1" title="Counting..."><img src="images/loading-small.gif"></span>
    469             <li><a href="sampleproc/rnaqc_plate_import.jsp?ID=<%=ID%>">Import RQS scores from Caliper well table file</a> <span class="counter" id="count.caliper-plates.2" title="Counting..."><img src="images/loading-small.gif"></span>
    470             </ul>
    471           </dd>
    472           <%
    473         }
    474         %>       
     481        <dl class="leftborder rightborder bottomborder has-lib-prep">
     482
     483        <dt>
     484          <base:icon image="<%=home+"/images/specimen.png" %>" />
     485          <span class="require-permission" data-role="SamplePrep" data-link="sampleproc/specimentube.jsp?ID=<%=ID%>"
     486            >Specimen tube registration</span>
     487        </dt>
     488        <dd>
     489          <ul>
     490          <li>Register new specimen tubes.
     491          <li>Update existing specimen tubes.
     492          </ul>
     493        </dd>
     494
     495        <dt>
     496          <base:icon image="<%=home+"/images/partition.png" %>" />
     497          <span class="require-permission" data-role="SamplePrep" data-link="sampleproc/partitionform.jsp?ID=<%=ID%>"
     498            >Partition wizard</span>
     499        </dt>
     500        <dd>
     501          <ul>
     502          <li>Register new partitions of existing specimens <span class="counter" id="count.specimen" title="Counting..."><img src="images/loading-small.gif"></span>
     503          </ul>
     504        </dd>
     505         
     506        <dt>
     507          <base:icon image="<%=home+"/images/extraction.png" %>" />
     508          DNA/RNA extraction wizards
     509        </dt>
     510        <dd>
     511          <ul>
     512          <li><span class="require-permission" data-role="SamplePrep" data-link="sampleproc/allprep_protocol.jsp?ID=<%=ID%>"
     513            >Lab tracking protocol for Allprep isolation</span> <span class="counter" id="count.lysate.1" title="Counting..."><img src="images/loading-small.gif"></span>
     514
     515          <li><span class="require-permission" data-role="SamplePrep" data-link="sampleproc/extraction_registration.jsp?ID=<%=ID%>"
     516            >DNA/RNA/FlowThrough registration</span> <span class="counter" id="count.lysate.2" title="Counting..."><img src="images/loading-small.gif"></span>
     517          </ul>
     518        </dd>
     519        <dt>
     520          <base:icon image="<%=home+"/images/rnaqc.png" %>" />
     521          RNA quality control wizards
     522        </dt>
     523        <dd>
     524          <ul>
     525          <li><span class="require-permission" data-role="SamplePrep" data-link="sampleproc/rnaqc_aliquot.jsp?ID=<%=ID%>"
     526            >Create aliquots on Bioanalyzer/Caliper plates</span> <span class="counter" id="count.rnaqc" title="Counting..."><img src="images/loading-small.gif"></span>
     527         
     528          <li><span class="require-permission" data-role="SamplePrep" data-link="sampleproc/rnaqc_plate_export.jsp?ID=<%=ID%>"
     529            >Export Caliper sample names and run parameters</span> <span class="counter" id="count.caliper-plates.1" title="Counting..."><img src="images/loading-small.gif"></span>
     530         
     531          <li><span class="require-permission" data-role="SamplePrep" data-link="sampleproc/rnaqc_plate_import.jsp?ID=<%=ID%>"
     532            >Import RQS scores from Caliper well table file</span> <span class="counter" id="count.caliper-plates.2" title="Counting..."><img src="images/loading-small.gif"></span>
     533          </ul>
     534        </dd>     
     535        </dl>
     536     
     537        <h3>Histology wizards</h3>
     538        <dl class="leftborder rightborder bottomborder">     
     539        <dt>
     540          <base:icon image="<%=home+"/images/histology.png" %>" />
     541          Embedding and staining wizards
     542        </dt>
     543        <dd>
     544          <ul>
     545          <li><span class="require-permission" data-role="Histology" data-link="sampleproc/histology_protocol.jsp?ID=<%=ID%>"
     546            >Lab tracking protocol for FFPE/HE</span> <span class="counter" id="count.histology-lists" title="Counting..."><img src="images/loading-small.gif"></span>
     547         
     548          <li><span class="require-permission" data-role="Histology" data-link="sampleproc/histology_block.jsp?ID=<%=ID%>"
     549            >Register paraffin blocks</span> <span class="counter" id="count.paraffin-blocks" title="Counting..."><img src="images/loading-small.gif"></span>
     550         
     551          <li><span class="require-permission" data-role="Histology" data-link="sampleproc/histology_glass.jsp?ID=<%=ID%>"
     552            >Register HE glass</span> <span class="counter" id="count.paraffin-blocks-without-heglass" title="Counting..."><img src="images/loading-small.gif"></span>
     553        </dd>
     554       
     555        <dt>
     556          <base:icon image="<%=home+"/images/microscope.png" %>" />
     557          Scoring wizard
     558        </dt>
     559        <dd>
     560          <li><span class="require-permission" data-role="Histology" data-link="sampleproc/histology_score.jsp?ID=<%=ID%>"
     561            >Score HE glass</span> <span class="counter" id="count.unscored-heglass" title="Counting..."><img src="images/loading-small.gif"></span>
     562          </ul>
     563        </dd>
    475564        </dl>
    476565     
     
    478567        <h3>Library preparation wizards</h3>
    479568        <dl class="leftborder rightborder bottomborder">
    480         <%
    481         if (hasCreateExtractPermission && hasCreateBioPlatePermission)
    482         {
    483           %>
    484           <dt>
    485             <base:icon image="<%=home+"/images/pipette.png" %>" />
    486             RNA to cDNA wizards
    487           </dt>
    488           <dd>
    489             <ul>
    490             <li><a href="libprep/select_rna.jsp?ID=<%=ID%>">Create new mRNA plate</a> <span class="counter" id="count.rna-without-mrna" title="Counting..."><img src="images/loading-small.gif"></span>
    491             <li><a href="libprep/mrna_protocol.jsp?ID=<%=ID%>">Lab protocols for mRNA and cDNA preparation</a> <span class="counter" id="count.mrna-plates.1" title="Counting..."><img src="images/loading-small.gif"></span>
    492             <li><a href="libprep/mrna_registration.jsp?ID=<%=ID%>">mRNA registration and quality control results</a> <span class="counter" id="count.mrna-plates.2" title="Counting..."><img src="images/loading-small.gif"></span>
    493             <li><a href="libprep/cdna_registration.jsp?ID=<%=ID%>">cDNA registration</a> <span class="counter" id="count.cdna-plates.1" title="Counting..."><img src="images/loading-small.gif"></span>
    494             </ul>
    495           </dd>
    496          
    497           <dt>
    498             <base:icon image="<%=home+"/images/libprep.png" %>" />
    499             Library preparation wizards
    500           </dt>
    501           <dd>
    502             <ul>
    503             <li><a href="libprep/assign_barcode.jsp?ID=<%=ID%>">Assign barcodes to cDNA plate</a> <span class="counter" id="count.cdna-plates-for-barcoding" title="Counting..."><img src="images/loading-small.gif"></span>
    504             <li><a href="libprep/libprep_protocol.jsp?ID=<%=ID%>">Lab protocols and files for library preparation</a> <span class="counter" id="count.lib-plates.1" title="Counting..."><img src="images/loading-small.gif"></span>
    505             <li><a href="libprep/libqc_registration.jsp?ID=<%=ID%>">Register quality control results</a> <span class="counter" id="count.lib-plates.2" title="Counting..."><img src="images/loading-small.gif"></span>
    506             <li><a href="libprep/lib_registration.jsp?ID=<%=ID%>">Library registration</a> <span class="counter" id="count.lib-plates.3" title="Counting..."><img src="images/loading-small.gif"></span>
    507             </ul>
    508           </dd>
    509           <dt>
    510             <base:icon image="<%=home+"/images/flowcell.png" %>" />
    511             Pooling and clustering wizards
    512           </dt>
    513           <dd>
    514             <ul>
    515             <li><a href="libprep/create_pools.jsp?ID=<%=ID%>">Create pooled libraries</a> <span class="counter" id="count.lib-plates-for-pooling" title="Counting..."><img src="images/loading-small.gif"></span>
    516             <li><a href="libprep/pool_protocol.jsp?ID=<%=ID%>">Lab protocols for pooling</a> <span class="counter" id="count.pools.1" title="Counting..."><img src="images/loading-small.gif"></span>
    517             <li><a href="libprep/pool_registration.jsp?ID=<%=ID%>">Register pooled libraries</a> <span class="counter" id="count.pools.2" title="Counting..."><img src="images/loading-small.gif"></span>
    518             <li><a href="libprep/create_flowcells.jsp?ID=<%=ID%>">Create flow cells</a> <span class="counter" id="count.pools.3" title="Counting..."><img src="images/loading-small.gif"></span>
    519             <li><a href="libprep/flowcell_protocol.jsp?ID=<%=ID%>">Lab protocol for clustering and sequencing startup</a> <span class="counter" id="count.flow-cells.1" title="Counting..."><img src="images/loading-small.gif"></span>
    520             <li><a href="libprep/flowcell_registration.jsp?ID=<%=ID%>">Register clustering and sequencing startup</a> <span class="counter" id="count.flow-cells.2" title="Counting..."><img src="images/loading-small.gif"></span>
    521             </ul>
    522           </dd>
    523           <%
    524         }
    525         %>
     569     
     570        <dt>
     571          <base:icon image="<%=home+"/images/pipette.png" %>" />
     572          RNA to cDNA wizards
     573        </dt>
     574        <dd>
     575          <ul>
     576          <li><span class="require-permission" data-role="LibraryPlateDesigner" data-link="libprep/select_rna.jsp?ID=<%=ID%>"
     577            >Create new mRNA plate</span> <span class="counter" id="count.rna-without-mrna" title="Counting..."><img src="images/loading-small.gif"></span>
     578         
     579          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/mrna_protocol.jsp?ID=<%=ID%>"
     580            >Lab protocols for mRNA and cDNA preparation</span> <span class="counter" id="count.mrna-plates.1" title="Counting..."><img src="images/loading-small.gif"></span>
     581         
     582          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/mrna_registration.jsp?ID=<%=ID%>"
     583            >mRNA registration and quality control results</span> <span class="counter" id="count.mrna-plates.2" title="Counting..."><img src="images/loading-small.gif"></span>
     584         
     585          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/cdna_registration.jsp?ID=<%=ID%>"
     586            >cDNA registration</span> <span class="counter" id="count.cdna-plates.1" title="Counting..."><img src="images/loading-small.gif"></span>
     587          </ul>
     588        </dd>
     589       
     590        <dt>
     591          <base:icon image="<%=home+"/images/libprep.png" %>" />
     592          Library preparation wizards
     593        </dt>
     594        <dd>
     595          <ul>
     596          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/assign_barcode.jsp?ID=<%=ID%>"
     597            >Assign barcodes to cDNA plate</span> <span class="counter" id="count.cdna-plates-for-barcoding" title="Counting..."><img src="images/loading-small.gif"></span>
     598         
     599          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/libprep_protocol.jsp?ID=<%=ID%>"
     600            >Lab protocols and files for library preparation</span> <span class="counter" id="count.lib-plates.1" title="Counting..."><img src="images/loading-small.gif"></span>
     601         
     602          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/libqc_registration.jsp?ID=<%=ID%>"
     603            >Register quality control results</span> <span class="counter" id="count.lib-plates.2" title="Counting..."><img src="images/loading-small.gif"></span>
     604         
     605          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/lib_registration.jsp?ID=<%=ID%>"
     606            >Library registration</span> <span class="counter" id="count.lib-plates.3" title="Counting..."><img src="images/loading-small.gif"></span>
     607          </ul>
     608        </dd>
     609        <dt>
     610          <base:icon image="<%=home+"/images/flowcell.png" %>" />
     611          Pooling and clustering wizards
     612        </dt>
     613        <dd>
     614          <ul>
     615          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/create_pools.jsp?ID=<%=ID%>"
     616            >Create pooled libraries</span> <span class="counter" id="count.lib-plates-for-pooling" title="Counting..."><img src="images/loading-small.gif"></span>
     617         
     618          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/pool_protocol.jsp?ID=<%=ID%>"
     619            >Lab protocols for pooling</span> <span class="counter" id="count.pools.1" title="Counting..."><img src="images/loading-small.gif"></span>
     620         
     621          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/pool_registration.jsp?ID=<%=ID%>"
     622            >Register pooled libraries</span> <span class="counter" id="count.pools.2" title="Counting..."><img src="images/loading-small.gif"></span>
     623         
     624          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/create_flowcells.jsp?ID=<%=ID%>"
     625            >Create flow cells</span> <span class="counter" id="count.pools.3" title="Counting..."><img src="images/loading-small.gif"></span>
     626         
     627          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/flowcell_protocol.jsp?ID=<%=ID%>"
     628            >Lab protocol for clustering and sequencing startup</span> <span class="counter" id="count.flow-cells.1" title="Counting..."><img src="images/loading-small.gif"></span>
     629         
     630          <li><span class="require-permission" data-role="LibPrep" data-link="libprep/flowcell_registration.jsp?ID=<%=ID%>"
     631            >Register clustering and sequencing startup</span> <span class="counter" id="count.flow-cells.2" title="Counting..."><img src="images/loading-small.gif"></span>
     632          </ul>
     633        </dd>
     634       
    526635        </dl>
    527636      </div>
     
    538647          <dt>
    539648            <base:icon image="<%=home + "/images/install.png" %>" />
    540             <a href="admin/install.jsp?ID=<%=ID%>">Installation wizard</a>
     649            <span class="require-permission" data-role="Administrator" data-link="admin/install.jsp?ID=<%=ID%>">Installation wizard</span>
    541650          </dt>
    542651          <dd>
     
    556665          <dt>
    557666            <base:icon image="<%=home + "/images/personal.png" %>"/>
    558             <a href="personal/persinfo.jsp?ID=<%=ID%>">Pathology referral form registration</a>
     667            <span class="require-permission" data-role="PatientCurator" data-link="personal/persinfo.jsp?ID=<%=ID%>"
     668              >Pathology referral form registration</span>
    559669          </dt>
    560670          <dd>
     
    571681          <dd>
    572682            <ul>
    573             <li><a href="personal/bloodform.jsp?ID=<%=ID%>">Register new/updated blood referral forms and patients</a>
    574             <li><a href="personal/bloodfollowupform.jsp?ID=<%=ID%>">Register new/updated follow-up blood referral forms</a>
     683            <li><span class="require-permission" data-role="PatientCurator" data-link="personal/bloodform.jsp?ID=<%=ID%>"
     684              >Register new/updated blood referral forms and patients</span>
     685             
     686            <li><span class="require-permission" data-role="PatientCurator" data-link="personal/bloodfollowupform.jsp?ID=<%=ID%>"
     687              >Register new/updated follow-up blood referral forms</span>
    575688            </ul>
    576689          </dd>
     
    578691          <dt>
    579692            <base:icon image="<%=home+"/images/consent.png" %>"/>
    580             <a href="personal/consentform.jsp?ID=<%=ID%>">Consent form registration</a>
     693            <span class="require-permission" data-role="PatientCurator" data-link="personal/consentform.jsp?ID=<%=ID%>"
     694              >Consent form registration</span>
    581695          </dt>
    582696          <dd>
     
    592706          <dd>
    593707            <ul>
    594             <li><a href="personal/export_monthly_oplist.jsp?ID=<%=ID%>">Export monthly operation list</a>
    595             <li><a href="personal/export_inca.jsp?ID=<%=ID%>">INCA export</a>
     708            <li><span class="require-permission" data-role="PatientCurator" data-link="personal/export_monthly_oplist.jsp?ID=<%=ID%>"
     709              >Export monthly operation list</span>
     710             
     711            <li><span class="require-permission" data-role="PatientCurator" data-link="personal/export_inca.jsp?ID=<%=ID%>"
     712              >INCA export</span>
    596713            </ul>
    597714          </dd>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java

    r2152 r2157  
    99import net.sf.basedb.core.AnnotationTypeCategory;
    1010import net.sf.basedb.core.DbControl;
    11 import net.sf.basedb.core.Group;
    1211import net.sf.basedb.core.Include;
    13 import net.sf.basedb.core.InvalidDataException;
    14 import net.sf.basedb.core.ItemNotFoundException;
    1512import net.sf.basedb.core.ItemQuery;
    1613import net.sf.basedb.core.Type;
     
    3431
    3532 
    36   /**
    37     The name of the "PatientCurator" group. Members of this group
    38     are allowed to use the personal information registration wizard.
    39   */
    40   public static final String GROUP_PATIENT_CURATOR = "PatientCurator";
    41 
    42 
    4333  /**
    4434    Default converter for date values to string values: yyyyMMdd
     
    8070  public static final Pattern CASE_NAME_PATTERN = Pattern.compile("\\d{7}(\\..*)?");
    8171 
    82   /**
    83     List all groups with the given name.
    84   */
    85   public static List<Group> listGroups(DbControl dc, String name)
    86   {
    87     ItemQuery<Group> query = Group.getQuery();
    88     query.restrict(Restrictions.eq(Hql.property("name"), Expressions.parameter("name", name, Type.STRING)));
    89     query.include(Include.ALL);
    90     return query.list(dc);
    91   }
    92  
    93   /**
    94     Find a single group with the given name. If exactly one is found it
    95     is returned, otherwise null is returned or an exception is thrown
    96     depending on the exceptionIfNotFound parameter.
    97   */
    98   public static Group findGroup(DbControl dc, String name, boolean exceptionIfNotFound)
    99   {
    100     List<Group> result = listGroups(dc, name);
    101     Group g = null;
    102     if (result.size() == 0)
    103     {
    104       if (exceptionIfNotFound) throw new ItemNotFoundException("Group["+name+"]");
    105     }
    106     else if (result.size() > 1)
    107     {
    108       if (exceptionIfNotFound) throw new InvalidDataException("Found > 1 Group["+name+"]");
    109     }
    110     else
    111     {
    112       g = result.get(0);
    113     }
    114     return g;
    115  
    116   }
    117 
    11872  /**
    11973    List all annotation types with the given name.
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r2141 r2157  
    2020import net.sf.basedb.core.AnnotationTypeCategory;
    2121import net.sf.basedb.core.Application;
     22import net.sf.basedb.core.BasicItem;
    2223import net.sf.basedb.core.BioMaterialList;
    2324import net.sf.basedb.core.BioPlateEventType;
     
    3435import net.sf.basedb.core.MimeType;
    3536import net.sf.basedb.core.MultiPermissions;
     37import net.sf.basedb.core.Nameable;
    3638import net.sf.basedb.core.Permission;
    3739import net.sf.basedb.core.PlateGeometry;
     
    4244import net.sf.basedb.core.SessionControl;
    4345import net.sf.basedb.core.SharedItem;
     46import net.sf.basedb.core.SystemItems;
    4447import net.sf.basedb.core.Tag;
    4548import net.sf.basedb.core.Type;
     49import net.sf.basedb.core.User;
    4650import net.sf.basedb.core.plugin.Plugin;
    4751import net.sf.basedb.core.query.Expressions;
     
    5761import net.sf.basedb.reggie.dao.PooledLibrary;
    5862import net.sf.basedb.reggie.dao.ReactionPlate;
     63import net.sf.basedb.reggie.dao.ReggieRole;
    5964import net.sf.basedb.reggie.dao.Rna;
    6065import net.sf.basedb.reggie.dao.Subtype;
     
    108113       
    109114        // Group checks
    110         jsonChecks.add(checkGroup(dc, Reggie.GROUP_PATIENT_CURATOR, createIfMissing));
    111 
    112         Group patientCurator = Reggie.findGroup(dc, Reggie.GROUP_PATIENT_CURATOR, false);
     115        jsonChecks.add(checkReggieRole(dc, ReggieRole.PATIENT_CURATOR, createIfMissing));
     116
     117        // Role checks
     118        jsonChecks.add(checkReggieRole(dc, ReggieRole.ADMINISTRATOR, createIfMissing));
     119        jsonChecks.add(checkReggieRole(dc, ReggieRole.SAMPLE_PREP, createIfMissing));
     120        jsonChecks.add(checkReggieRole(dc, ReggieRole.HISTOLOGY, createIfMissing));
     121        jsonChecks.add(checkReggieRole(dc, ReggieRole.LIBRARY_PREP, createIfMissing));
     122        jsonChecks.add(checkReggieRole(dc, ReggieRole.LIBRARY_PLATE_DESIGNER, createIfMissing));
     123        jsonChecks.add(checkReggieRole(dc, ReggieRole.SECONDARY_ANALYSIS, createIfMissing));
     124
     125        Group patientCurator = ReggieRole.PATIENT_CURATOR.get(dc);
    113126        PermissionOptions sharedToPatientCurator = null;
    114127        if (patientCurator != null)
     
    440453        if (createIfMissing) dc.commit();
    441454      }
     455     
     456      else if ("GetPermissions".equals(cmd))
     457      {
     458        dc = sc.newDbControl();
     459        boolean isRoot = sc.getLoggedInUserId() == SystemItems.getId(User.ROOT);
     460        JSONObject jsonPermissions = new JSONObject();
     461        jsonPermissions.put("Administrator", isRoot|| ReggieRole.ADMINISTRATOR.isMember(dc) ? 1 : 0);
     462        jsonPermissions.put("PatientCurator", ReggieRole.PATIENT_CURATOR.isMember(dc) ? 1 : 0);
     463        jsonPermissions.put("SamplePrep", ReggieRole.SAMPLE_PREP.isMember(dc) ? 1 : 0);
     464        jsonPermissions.put("Histology", ReggieRole.HISTOLOGY.isMember(dc) ? 1 : 0);
     465        jsonPermissions.put("LibraryPrep", ReggieRole.LIBRARY_PREP.isMember(dc) ? 1 : 0);
     466        jsonPermissions.put("LibraryPlateDesigner", ReggieRole.LIBRARY_PLATE_DESIGNER.isMember(dc) ? 1 : 0);
     467        jsonPermissions.put("SecondaryAnalysis", ReggieRole.SECONDARY_ANALYSIS.isMember(dc) ? 1 : 0);
     468       
     469        json.put("permissions", jsonPermissions);
     470        dc.close();
     471      }
    442472    }
    443473    catch (Throwable t)
     
    457487   
    458488  }
     489 
    459490 
    460491  /**
     
    657688 
    658689  /**
    659     Create a group with the given options. The group is created in
     690    Create a group or role with the given options. The item is created in
    660691    a separate transaction.
    661692  */
    662   public Group createGroup(SessionControl sc, String name)
    663   {
    664     Group g = null;
     693  public <T extends BasicItem<?> & Nameable> T createReggieRole(SessionControl sc, ReggieRole<T> role)
     694  {
     695    T r = null;
    665696    DbControl dc = sc.newDbControl();
    666697    try
    667698    {
    668       g = Group.getNew(dc);
    669       g.setName(name);
    670       dc.saveItem(g);
     699      r = role.create(dc);
     700      r.setName(role.getName());
     701      dc.saveItem(r);
    671702      dc.commit();
    672703    }
     
    675706      if (dc != null) dc.close();
    676707    }
    677     return g;
    678   }
    679 
    680   /**
    681     Check for an existing group with the given options. A JSONObject is returned
    682     with the result. The following keys are used:
     708    return r;
     709  }
     710
     711  /**
     712    Check for an existing reggie role (a BASE role or group) with the given options.
     713    A JSONObject is returned with the result. The following keys are used:
    683714    <ul>
    684     <li>itemType: GROUP
    685     <li>name: The name of the group
    686     <li>id: The id of the group if it exists
     715    <li>itemType: GROUP or ROLE
     716    <li>name: The name of the item
     717    <li>id: The id of the item if it exists
    687718    <li>status: ok, error, or missing
    688719    <li>message: A descriptive message in case of an error
     
    690721  */
    691722  @SuppressWarnings("unchecked")
    692   public JSONObject checkGroup(DbControl dc, String name, boolean createIfMissing)
     723  public JSONObject checkReggieRole(DbControl dc, ReggieRole<? extends BasicItem> role, boolean createIfMissing)
    693724  {
    694725    JSONObject json = new JSONObject();
    695726    JSONArray jsonMessages = new JSONArray();
    696     json.put("itemType", Item.GROUP.name());
    697     json.put("name", name);
    698    
    699     List<Group> result = Reggie.listGroups(dc, name);
     727    json.put("itemType", role.getActualType().name());
     728    json.put("name", role.getName());
     729   
     730    List<? extends BasicItem> result = role.list(dc);
    700731    if (result.size() == 0)
    701732    {
    702733      if (createIfMissing)
    703734      {
    704         Group g = createGroup(dc.getSessionControl(), name);
     735        BasicItem g = createReggieRole(dc.getSessionControl(), role);
    705736        json.put("id", g.getId());
    706737        json.put("status", "ok");
     
    716747    {
    717748      json.put("status", "error");
    718       jsonMessages.add("Found > 1 group");
     749      jsonMessages.add("Found > 1 " + role.getActualType().toString());
    719750    }
    720751    else
    721752    {
    722       Group g = result.get(0);
     753      BasicItem g = result.get(0);
    723754      json.put("id", g.getId());
    724755      json.put("status", "ok");
Note: See TracChangeset for help on using the changeset viewer.