-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa39fa1
commit ae3df2e
Showing
31 changed files
with
1,593 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
|
||
use App\Facades\EntityFacade; | ||
use App\Models\User; | ||
use App\Traits\DumpFromGit\CreateCategoriesAndGroupsTrait; | ||
use App\Traits\DumpFromGit\CreateEntitiesTrait; | ||
use App\Traits\DumpFromGit\CreateFederationTrait; | ||
use App\Traits\DumpFromGit\EntitiesHelp\FixEntityTrait; | ||
use App\Traits\DumpFromGit\EntitiesHelp\UpdateEntity; | ||
use App\Traits\EntityFolderTrait; | ||
use App\Traits\FederationTrait; | ||
use App\Traits\GitTrait; | ||
use Illuminate\Console\Command; | ||
use App\Traits\ValidatorTrait; | ||
use Illuminate\Support\Facades\Artisan; | ||
|
||
|
||
class DumpFromGit extends Command | ||
{ | ||
use GitTrait, ValidatorTrait,EntityFolderTrait; | ||
use CreateFederationTrait,CreateEntitiesTrait,CreateCategoriesAndGroupsTrait; | ||
use UpdateEntity,FederationTrait,FixEntityTrait; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:dump-from-git'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Command description'; | ||
|
||
|
||
|
||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
$firstAdminId = User::where('admin', 1)->first()->id; | ||
$this->initializeGit(); | ||
$this->createFederations(); | ||
$this->createEntities($firstAdminId); | ||
$this->createCategoriesAndGroups(); | ||
$this->updateGroupsAndCategories(); | ||
$this->updateEntitiesXml(); | ||
$this->updateFederationFolders(); | ||
$this->fixEntities(); | ||
$this->createAllMetadataFiles(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Entity; | ||
use App\Traits\DumpFromGit\EntitiesHelp\FixEntityTrait; | ||
use App\Traits\ValidatorTrait; | ||
use Illuminate\Console\Command; | ||
|
||
class ValidateMetaConsole extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:val'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Command description'; | ||
|
||
|
||
use ValidatorTrait,FixEntityTrait; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
|
||
private function doc() | ||
{ | ||
foreach (Entity::select()->get() as $entity) | ||
{ | ||
$ent = Entity::where('id', $entity->id)->select()->first(); | ||
|
||
|
||
// $res = json_decode($this->validateMetadata($ent->metadata),true); | ||
$res = json_decode($this->validateMetadata($ent->xml_file,true),true); | ||
$res['ent_id'] = $ent->id; | ||
$errorArray = $res['errorArray']; | ||
|
||
|
||
if($res['code']==1) | ||
{ | ||
dump($res); | ||
} | ||
else | ||
{ | ||
dump($res['ent_id']); | ||
} | ||
} | ||
} | ||
|
||
private function meta() | ||
{ | ||
foreach (Entity::select()->get() as $entity) | ||
{ | ||
|
||
$ent = Entity::where('id', $entity->id)->select()->first(); | ||
|
||
$curr = 345; | ||
|
||
if($ent->id < $curr) | ||
continue; | ||
if($ent->id > $curr) | ||
break; | ||
|
||
|
||
$res = json_decode($this->validateMetadata($ent->metadata),true); | ||
$res['ent_id'] = $ent->id; | ||
|
||
|
||
dump($res); | ||
if( $res['code']==1) | ||
{ | ||
|
||
} | ||
} | ||
} | ||
|
||
|
||
public function handle() | ||
{ | ||
|
||
// $this->fixEntities(); | ||
$this->doc(); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class EntityFacade extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'entity'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Facades\EntityFacade; | ||
use App\Models\Entity; | ||
use App\Models\Federation; | ||
use App\Traits\FederationTrait; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Support\Facades\Log; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
class SaveMetadataToFolders implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
/** | ||
* Create a new job instance. | ||
*/ | ||
|
||
protected int $entity_id; | ||
protected int $federation_id; | ||
|
||
public function __construct($entity_id, $federation_id) | ||
{ | ||
$this->entity_id = $entity_id; | ||
$this->federation_id = $federation_id; | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
*/ | ||
public function handle(): void | ||
{ | ||
EntityFacade::SaveEntityMetadataToFile($this->entity_id,$this->federation_id); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use App\Services\EntityService; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class EntityFacadeServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register services. | ||
*/ | ||
public function register(): void | ||
{ | ||
$this->app->singleton('entity', function ($app) { | ||
return new EntityService(); | ||
}); | ||
} | ||
|
||
/** | ||
* Bootstrap services. | ||
*/ | ||
public function boot(): void | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
namespace App\Services; | ||
use App\Models\Entity; | ||
use App\Models\Federation; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
class EntityService | ||
{ | ||
public function SaveEntityMetadataToFile($entity_id,$federation_id) | ||
{ | ||
$entity = Entity::find($entity_id); | ||
$federation = Federation::find($federation_id); | ||
|
||
if(!$entity || !$federation){ | ||
return; | ||
} | ||
$folderName = $federation->name; | ||
$fileName = $entity->file; | ||
if(!Storage::disk('metadata')->exists($folderName)) | ||
{ | ||
Storage::disk('metadata')->makeDirectory($folderName); | ||
} | ||
$filePath = $folderName . '/' . $fileName . 'xml'; | ||
$content = $entity->xml_file; | ||
Storage::disk('metadata')->put($filePath, $content); | ||
} | ||
} |
Oops, something went wrong.