Skip to content

Commit

Permalink
Merge pull request #34 from BioKIC/master
Browse files Browse the repository at this point in the history
code update
  • Loading branch information
mandrewj authored Sep 7, 2022
2 parents 528f53f + 06298cc commit 3702655
Show file tree
Hide file tree
Showing 96 changed files with 3,139 additions and 1,249 deletions.
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,19 @@ This fork of the Symbiota code is actively being developed by the Biodiversity K
Even though BioKIC code developments are regularly pushed back to this repository, we recommend that you download/fork code directly from the
BioKIC/Symbiota repository (https://github.com/BioKIC/Symbiota) to ensure that you obtain the most recently code changes.


# Welcome to the Symbiota code repository

### ABOUT THIS SOFTWARE

The Symbiota Software Project is building a library of webtools to aid biologists in establishing specimen based virtual floras and faunas. This project developed from the realization that complex, information rich biodiversity portals are best built through collaborative efforts between software developers, biologist, wildlife managers, and citizen scientist. The central premise of this open source software project is that through a partnership between software engineers and scientific community, higher quality and more publicly useful biodiversity portals can be built. An open source software framework allows the technicians to create the tools, thus freeing the biologist to concentrate their efforts on the curation of quality datasets. In this manor, we can create
something far greater than a single entity is capable of doing on their own.

More information about this project can be accessed through:

(https://symbiota.org)

More information about this project can be accessed through [https://symbiota.org](https://symbiota.org).
For documentation and user guides please visit [Symbiota Docs](https://symbiota.org/docs).

## ACKNOWLEDGEMENTS

Symbiota has been generously funded by the National Science
Foundation (DBI-0743827) from 15 July 2008 to 30 June 2011
(Estimated). The Global Institute of Sustainability
(GIOS) at Arizona State University has also been a major
supporters of the Symbiota initiative since the very beginning.
Arizona State University Vascular Plant and Lichen Herbarium have
been intricately involved in the development from the start.
Sky Island Alliance and the Arizona-Sonora Desert Museum have both
been long-term participants in the development of this product.
Symbiota has been generously funded by the National Science Foundation (DBI-0743827) from 15 July 2008 to 30 June 2011 (Estimated). The Global Institute of Sustainability (GIOS) at Arizona State University has also been a major supporters of the Symbiota initiative since the very beginning. Arizona State University Vascular Plant and Lichen Herbarium have been intricately involved in the development from the start. Sky Island Alliance and the Arizona-Sonora Desert Museum have both been long-term participants in the development of this product.

## FEATURES

Expand All @@ -43,7 +32,7 @@ been long-term participants in the development of this product.

## LIMITATIONS

* Tested thoroughly on Linux and Window operating systems
* Tested thoroughly on Linux and Windows operating systems
* Code should work with an PHP enabled web server, though central development and testing done using Apache HTTP Server


Expand Down
3 changes: 2 additions & 1 deletion admin/portalindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ function validateHandshakeForm(f){
echo '<div><label>Path</label>: '.$profileArr['path'].'</div>';
echo '<div><label>Query string</label>: '.$profileArr['queryStr'].'</div>';
echo '<div><label>Stored procedure (cleaning)</label>: '.$profileArr['cleanUpSp'].'</div>';
echo '<div>Go to <a href="../collections/admin/specuploadmap.php?uploadtype=13&uspid='.$uspid.'&collid='.$collid.'" target="_blank">Import Profile</a></div>';
echo '<div>Display all <a href="../collections/admin/specuploadmanagement.php?collid='.$collid.'" target="_blank">Import Profiles</a></div>';
echo '<div>Initiate <a href="../collections/admin/specuploadmap.php?uploadtype=13&uspid='.$uspid.'&collid='.$collid.'" target="_blank">Data Import</a></div>';
echo '</div>';
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/app/Http/Controllers/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers;

use App\Collection;
use App\Models\Collection;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

Expand Down
29 changes: 16 additions & 13 deletions api/app/Http/Controllers/InstallationController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace App\Http\Controllers;

use App\PortalIndex;
use App\Models\PortalIndex;
use Illuminate\Http\Request;

class InstallationController extends Controller{
Expand Down Expand Up @@ -162,15 +162,16 @@ public function pingPortal(Request $request){
* )
*/
public function portalHandshake($id, Request $request){
$responseArr = array();
$responseArr = array( 'status' => 500, 'error' => 'Unknown error' );
$portalObj = PortalIndex::where('guid',$id)->get();
if($portalObj->count()){
$responseArr['status'] = true;
$responseArr['status'] = 200;
$responseArr['message'] = 'Portal previously registered';
unset($responseArr['error']);
}
elseif($id == $_ENV['PORTAL_GUID']){
//Make sure touch isn't referring to self
$responseArr['status'] = false;
$responseArr['status'] = 400;
$responseArr['error'] = 'Registration failed: handshake is referencing self';
}
elseif($request->has('endpoint')){
Expand All @@ -186,8 +187,9 @@ public function portalHandshake($id, Request $request){
try {
//Register remote
$portalObj = PortalIndex::create($remote);
$responseArr['status'] = true;
$responseArr['status'] = 200;
$responseArr['message'] = 'Remote portal registered successfully';
unset($responseArr['error']);
//Register all portals listed within remote, if not alreay registered
$urlInstallation = $baseUrl.'/api/v2/installation';
if($remoteInstallationArr = $this->getAPIResponce($urlInstallation)){
Expand All @@ -207,28 +209,29 @@ public function portalHandshake($id, Request $request){
}
}
}
$responseArr['Current registered remotes obtained from remote library'] = $currentRegistered;
$responseArr['Additional new registrations obtained from remote library'] = $newRegistration;
$responseArr['Currently registered remotes'] = $currentRegistered;
$responseArr['Newly registrations remotes'] = $newRegistration;
}
else $responseArr['error'] = 'Unable to obtain remote installation listing: '.$urlInstallation;
} catch(\Illuminate\Database\QueryException $ex){
$responseArr['status'] = false;
}
catch(\Illuminate\Database\QueryException $ex){
$responseArr['status'] = 503;
$responseArr['error'] = 'Registration failed: Unable insert database record: '.$ex->getMessage();
}
}
else{
$responseArr['status'] = false;
$responseArr['status'] = 422;
$responseArr['error'] = 'Registration failed: Supplied and returned remote GUIDs not matching ('.$id.' != '.$remote['guid'].') ';
}
}
else{
$responseArr['status'] = false;
$responseArr['error'] = 'Registration failed: Unable to obtain data from endpoint: '.$urlPing;
$responseArr['status'] = 422;
$responseArr['error'] = 'Registration failed: Endpoint illegal or non-functional: '.$urlPing;
}
}
}
else{
$responseArr['status'] = false;
$responseArr['status'] = 422;
$responseArr['error'] = 'Registration failed: Unable to obtain portal endpoint';
}
$responseArr['results'] = $portalObj;
Expand Down
48 changes: 25 additions & 23 deletions api/app/Http/Controllers/InventoryController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace App\Http\Controllers;

use App\Inventory;
use App\Models\Inventory;
use Illuminate\Http\Request;

class InventoryController extends Controller{
Expand Down Expand Up @@ -57,11 +57,11 @@ public function showAllInventories(Request $request){

$eor = false;
$retObj = [
"offset" => (int)$offset,
"limit" => (int)$limit,
"endOfRecords" => $eor,
"count" => $fullCnt,
"results" => $result
'offset' => (int)$offset,
'limit' => (int)$limit,
'endOfRecords' => $eor,
'count' => $fullCnt,
'results' => $result
];
return response()->json($retObj);
}
Expand Down Expand Up @@ -90,12 +90,8 @@ public function showAllInventories(Request $request){
* )
*/
public function showOneInventory($id, Request $request){
$inventoryObj = null;
if(is_numeric($id)) $inventoryObj = Inventory::find($id);
else{
$inventoryObj = Inventory::where('recordID', $id)->first();
if(!$inventoryObj->count()) $inventoryObj = Inventory::where('guid', $id)->first();
}
$id = $this->getClid($id);
$inventoryObj = Inventory::find($id);
if(!$inventoryObj->count()) $inventoryObj = ['status' =>false, 'error' => 'Unable to locate inventory based on identifier'];
return response()->json($inventoryObj);
}
Expand Down Expand Up @@ -138,12 +134,8 @@ public function showOneInventoryTaxa($id, Request $request){
$limit = $request->input('limit',100);
$offset = $request->input('offset',0);

$inventoryObj = null;
if(is_numeric($id)) $inventoryObj = Inventory::find($id);
else{
$inventoryObj = Inventory::where('recordID', $id)->first();
if(!$inventoryObj->count()) $inventoryObj = Inventory::where('guid', $id)->first();
}
$id = $this->getClid($id);
$inventoryObj = Inventory::find($id);
$fullCnt = $inventoryObj->taxa()->count();
$result = null;
if($fullCnt){
Expand All @@ -154,12 +146,22 @@ public function showOneInventoryTaxa($id, Request $request){
$eor = false;
if(($offset + $limit) >= $fullCnt) $eor = true;
$retObj = [
"offset" => (int)$offset,
"limit" => (int)$limit,
"endOfRecords" => $eor,
"count" => $fullCnt,
"results" => $result
'offset' => (int)$offset,
'limit' => (int)$limit,
'endOfRecords' => $eor,
'count' => $fullCnt,
'results' => $result
];
return response()->json($retObj);
}

//Helper function
protected function getClid($id){
if(is_numeric($id)) $clid = $id;
else{
$clid = Inventory::where('recordID', $id)->first()->value('clid');
if(!$clid) $clid = Inventory::where('guid', $id)->first()->value('clid');
}
return $clid;
}
}
51 changes: 51 additions & 0 deletions api/app/Http/Controllers/InventoryPackageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
namespace App\Http\Controllers;

use App\Models\Inventory;
use App\Models\Media;
use App\Models\TaxonomyDescription;
use App\Models\TaxonomyDescriptionStatement;
use Illuminate\Http\Request;

class InventoryPackageController extends InventoryController{
/**
* Inventory package controller instance.
*
* @return void
*/
public function __construct(){
}

public function oneInventoryDataPackage($id, Request $request){
$this->validate($request, [
'includeDescriptions' => 'integer',
'descriptionLimit' => 'integer',
'includeImages' => 'integer',
'imageLimit' => 'integer'
]);
$includeDescriptions = $request->input('includeDescriptions', 0);
$descriptionLimit = $request->input('descriptionLimit', 1);
$includeImages = $request->input('includeImages', 0);
$imageLimit = $request->input('imageLimit', 3);

$id = $this->getClid($id);
$inventoryObj = Inventory::find($id);
$inventoryObj->taxa;
foreach($inventoryObj->taxa as $taxaObj){
if($includeImages) $taxaObj->media = Media::where('tid', $taxaObj->tid)->orderBy('sortSequence')->take($imageLimit)->get();
if($includeDescriptions){
$description = TaxonomyDescription::where('tid', $taxaObj->tid)->orderBy('displayLevel')->take($descriptionLimit)->get();
foreach($description as $descrObj){
$descrObj->statements = TaxonomyDescriptionStatement::where('tdbid', $descrObj->tdbid)->get();
}
$taxaObj->textDescription = $description;
}

}
$result = $inventoryObj;
if(!$result->count()) $result = ['status' =>false, 'error' => 'Unable to locate inventory based on identifier'];

return response()->json($result);
}

}
23 changes: 8 additions & 15 deletions api/app/Http/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,41 @@

namespace App\Http\Controllers;

use App\Media;
use App\Models\Media;
use Illuminate\Http\Request;

class MediaController extends Controller
{
class MediaController extends Controller{
/**
* Media controller instance.
*
* @return void
*/
public function __construct()
{
public function __construct(){

}

public function showAllMedia()
{
public function showAllMedia(){
return response()->json(Media::skip(0)->take(100)->get());
}

public function showOneMedia($id)
{
public function showOneMedia($id){
return response()->json(Media::find($id));
}

public function create(Request $request)
{
public function create(Request $request){
$media = Media::create($request->all());

return response()->json($media, 201);
}

public function update($id, Request $request)
{
public function update($id, Request $request){
$media = Media::findOrFail($id);
$media->update($request->all());

return response()->json($media, 200);
}

public function delete($id)
{
public function delete($id){
Media::findOrFail($id)->delete();
return response('Media object deleted successfully', 200);
}
Expand Down
47 changes: 47 additions & 0 deletions api/app/Http/Controllers/MorphologyController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
namespace App\Http\Controllers;

use App\Models\MorphologyCharacter;
use App\Models\PortalIndex;
use Illuminate\Http\Request;

class MorphologyController extends Controller{
/**
* Taxon Morphology controller instance.
*
* @return void
*/
public function __construct(){
}

public function showAllCharacters(Request $request){
$this->validate($request, [
'limit' => 'integer',
'offset' => 'integer'
]);
$limit = $request->input('limit',100);
$offset = $request->input('offset',0);

$fullCnt = PortalIndex::count();
$result = PortalIndex::skip($offset)->take($limit)->get();

$eor = false;
$retObj = [
"offset" => (int)$offset,
"limit" => (int)$limit,
"endOfRecords" => $eor,
"count" => $fullCnt,
"results" => $result
];
return response()->json($retObj);
}

public function showOneCharacter($id, Request $request){
$portalObj = null;
if(is_numeric($id)) $portalObj = PortalIndex::find($id);
else $portalObj = PortalIndex::where('guid',$id)->first();
if(!$portalObj->count()) $portalObj = ["status"=>false,"error"=>"Unable to locate installation based on identifier"];
return response()->json($portalObj);
}

}
Loading

0 comments on commit 3702655

Please sign in to comment.