2020-05-06 07:59:57 +02:00
< ? php
App :: uses ( 'AppModel' , 'Model' );
class GalaxyClusterRelation extends AppModel
{
public $useTable = 'galaxy_cluster_relations' ;
public $recursive = - 1 ;
public $actsAs = array (
'Containable' ,
);
public $validate = array (
2020-05-07 11:03:18 +02:00
'referenced_galaxy_cluster_type' => array (
'stringNotEmpty' => array (
'rule' => array ( 'stringNotEmpty' )
)
),
2020-05-25 10:04:07 +02:00
'galaxy_cluster_uuid' => array (
'uuid' => array (
'rule' => array ( 'custom' , '/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/' ),
'message' => 'Please provide a valid UUID'
),
2020-05-07 12:30:05 +02:00
),
2020-05-07 11:03:18 +02:00
'referenced_galaxy_cluster_uuid' => array (
'uuid' => array (
'rule' => array ( 'custom' , '/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/' ),
'message' => 'Please provide a valid UUID'
),
),
'distribution' => array (
'rule' => array ( 'inList' , array ( '0' , '1' , '2' , '3' , '4' )),
'message' => 'Options: Your organisation only, This community only, Connected communities, All communities, Sharing group' ,
'required' => true
)
2020-05-06 07:59:57 +02:00
);
public $belongsTo = array (
2020-05-25 10:04:07 +02:00
'SourceCluster' => array (
2020-05-06 07:59:57 +02:00
'className' => 'GalaxyCluster' ,
'foreignKey' => 'galaxy_cluster_id' ,
2020-05-07 11:03:18 +02:00
),
2020-05-25 10:04:07 +02:00
'TargetCluster' => array (
2020-05-07 11:03:18 +02:00
'className' => 'GalaxyCluster' ,
'foreignKey' => 'referenced_galaxy_cluster_id' ,
),
'SharingGroup' => array (
'className' => 'SharingGroup' ,
'foreignKey' => 'sharing_group_id'
2020-05-25 10:04:07 +02:00
),
2020-05-06 07:59:57 +02:00
);
public $hasMany = array (
'GalaxyClusterRelationTag' => array ( 'dependent' => true ),
);
public function beforeValidate ( $options = array ())
{
parent :: beforeValidate ();
return true ;
}
2020-06-08 11:10:59 +02:00
public function afterFind ( $results , $primary = false )
{
foreach ( $results as $k => $result ) {
if ( isset ( $results [ $k ][ 'TargetCluster' ]) && is_null ( $results [ $k ][ 'TargetCluster' ][ 'id' ])) {
$results [ $k ][ 'TargetCluster' ] = array ();
}
}
return $results ;
}
2020-05-07 11:03:18 +02:00
public function buildConditions ( $user )
{
$this -> Event = ClassRegistry :: init ( 'Event' );
$conditions = array ();
if ( ! $user [ 'Role' ][ 'perm_site_admin' ]) {
2020-06-12 15:08:01 +02:00
$alias = $this -> alias ;
2020-05-07 11:03:18 +02:00
$sgids = $this -> Event -> cacheSgids ( $user , true );
2020-06-12 15:58:24 +02:00
$gcids = $this -> SourceCluster -> cacheGalaxyClusterIDs ( $user );
2020-05-07 11:03:18 +02:00
$conditions [ 'AND' ][ 'OR' ] = array (
2020-06-12 15:58:24 +02:00
" ${ alias } .galaxy_cluster_id " => $gcids ,
2020-05-07 11:03:18 +02:00
array (
'AND' => array (
2020-06-12 15:08:01 +02:00
" ${ alias } .distribution > " => 0 ,
" ${ alias } .distribution < " => 4
2020-05-07 11:03:18 +02:00
),
),
array (
'AND' => array (
2020-06-12 15:08:01 +02:00
" ${ alias } .sharing_group_id " => $sgids ,
" ${ alias } .distribution " => 4
2020-05-07 11:03:18 +02:00
)
)
);
}
return $conditions ;
}
2020-05-11 16:55:18 +02:00
public function fetchRelations ( $user , $options , $full = false )
2020-05-07 12:30:05 +02:00
{
$params = array (
'conditions' => $this -> buildConditions ( $user ),
'recursive' => - 1
);
if ( ! empty ( $options [ 'contain' ])) {
$params [ 'contain' ] = $options [ 'contain' ];
2020-05-11 16:55:18 +02:00
} elseif ( $full ) {
2020-05-25 10:04:07 +02:00
$params [ 'contain' ] = array ( 'SharingGroup' , 'SourceCluster' , 'TargetCluster' );
2020-05-07 12:30:05 +02:00
}
if ( isset ( $options [ 'fields' ])) {
$params [ 'fields' ] = $options [ 'fields' ];
}
if ( isset ( $options [ 'conditions' ])) {
$params [ 'conditions' ][ 'AND' ][] = $options [ 'conditions' ];
}
if ( isset ( $options [ 'group' ])) {
$params [ 'group' ] = empty ( $options [ 'group' ]) ? $options [ 'group' ] : false ;
}
$relations = $this -> find ( 'all' , $params );
foreach ( $relations as $i => $relation ) {
2020-05-07 15:15:14 +02:00
if ( $relation [ 'GalaxyClusterRelation' ][ 'distribution' ] != 4 ) {
2020-05-07 12:30:05 +02:00
unset ( $relation [ $i ][ 'SharingGroup' ]);
}
}
return $relations ;
}
2020-05-06 07:59:57 +02:00
public function getExistingRelationships ()
{
2020-05-06 11:44:53 +02:00
$existingRelationships = $this -> find ( 'list' , array (
2020-05-06 07:59:57 +02:00
'recursive' => - 1 ,
2020-06-12 10:25:01 +02:00
'fields' => array ( 'referenced_galaxy_cluster_type' , 'referenced_galaxy_cluster_type' ),
2020-05-06 11:44:53 +02:00
'group' => array ( 'referenced_galaxy_cluster_type' )
2020-05-06 07:59:57 +02:00
), false , false );
return $existingRelationships ;
}
public function deleteRelations ( $conditions )
{
$this -> deleteAll ( $conditions , false , false );
}
public function massageRelationTag ( $cluster )
{
2020-06-12 15:08:01 +02:00
if ( ! empty ( $cluster [ 'GalaxyCluster' ][ $this -> alias ])) {
foreach ( $cluster [ 'GalaxyCluster' ][ $this -> alias ] as $k => $relation ) {
2020-05-06 07:59:57 +02:00
if ( ! empty ( $relation [ 'GalaxyClusterRelationTag' ])) {
foreach ( $relation [ 'GalaxyClusterRelationTag' ] as $relationTag ) {
2020-06-12 15:08:01 +02:00
$cluster [ 'GalaxyCluster' ][ $this -> alias ][ $k ][ 'Tag' ][] = $relationTag [ 'Tag' ];
2020-05-06 07:59:57 +02:00
}
2020-05-29 11:36:34 +02:00
}
2020-06-12 15:08:01 +02:00
unset ( $cluster [ 'GalaxyCluster' ][ $this -> alias ][ $k ][ 'GalaxyClusterRelationTag' ]);
2020-05-29 11:36:34 +02:00
}
}
2020-05-06 07:59:57 +02:00
return $cluster ;
}
2020-05-07 12:30:05 +02:00
2020-06-09 10:08:36 +02:00
public function saveRelations ( $user , $cluster , $relations , $capture = false , $force = false )
{
$errors = array ();
foreach ( $relations as $k => $relation ) {
$saveResult = $this -> saveRelation ( $user , $cluster , $relation , $capture = $capture , $force = $force );
$errors = array_merge ( $errors , $saveResult );
}
return $errors ;
}
public function saveRelation ( $user , $cluster , $relation , $capture = false , $force = false )
2020-05-07 12:30:05 +02:00
{
2020-05-07 16:17:44 +02:00
$errors = array ();
2020-05-07 12:30:05 +02:00
if ( ! $user [ 'Role' ][ 'perm_galaxy_editor' ] && ! $user [ 'Role' ][ 'perm_site_admin' ]) {
2020-05-07 16:17:44 +02:00
$errors [] = __ ( 'Incorrect permission' );
return $errors ;
2020-05-07 12:30:05 +02:00
}
2020-06-09 10:08:36 +02:00
if ( ! isset ( $relation [ 'GalaxyClusterRelation' ]) && ! empty ( $relation )) {
$relation = array ( 'GalaxyClusterRelation' => $relation );
}
$relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_uuid' ] = $cluster [ 'uuid' ];
2020-05-29 10:02:17 +02:00
2020-05-07 12:30:05 +02:00
$existingRelation = $this -> find ( 'first' , array ( 'conditions' => array (
2020-05-25 10:04:07 +02:00
'GalaxyClusterRelation.galaxy_cluster_uuid' => $relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_uuid' ],
'GalaxyClusterRelation.referenced_galaxy_cluster_uuid' => $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ],
2020-05-07 12:30:05 +02:00
'GalaxyClusterRelation.referenced_galaxy_cluster_type' => $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_type' ],
)));
if ( ! empty ( $existingRelation )) {
2020-05-29 10:02:17 +02:00
if ( ! $force ) {
$errors [] = __ ( 'Relation already exists' );
return $errors ;
} else {
$relation [ 'GalaxyClusterRelation' ][ 'id' ] = $existingRelation [ 'GalaxyClusterRelation' ][ 'id' ];
}
} else {
$this -> create ();
2020-05-07 12:30:05 +02:00
}
2020-05-07 16:17:44 +02:00
if ( empty ( $errors )) {
2020-05-25 17:02:26 +02:00
$relation = $this -> syncUUIDsAndIDs ( $user , $relation );
2020-05-07 16:17:44 +02:00
$saveSuccess = $this -> save ( $relation );
if ( $saveSuccess ) {
$savedRelation = $this -> find ( 'first' , array (
'conditions' => array ( 'id' => $this -> id ),
'recursive' => - 1
));
2020-06-09 10:08:36 +02:00
$tags = array ();
if ( ! empty ( $relation [ 'GalaxyClusterRelation' ][ 'tags' ])) {
$tags = $relation [ 'GalaxyClusterRelation' ][ 'tags' ];
} elseif ( ! empty ( $relation [ 'GalaxyClusterRelation' ][ 'GalaxyClusterRelationTag' ])) {
$tags = $relation [ 'GalaxyClusterRelation' ][ 'GalaxyClusterRelationTag' ];
2020-06-09 12:57:19 +02:00
$tags = Hash :: extract ( $tags , '{n}.name' );
} elseif ( ! empty ( $relation [ 'GalaxyClusterRelation' ][ 'Tag' ])) {
$tags = $relation [ 'GalaxyClusterRelation' ][ 'Tag' ];
$tags = Hash :: extract ( $tags , '{n}.name' );
2020-06-09 10:08:36 +02:00
}
2020-06-09 12:57:19 +02:00
2020-06-09 10:08:36 +02:00
if ( ! empty ( $tags )) {
$tagSaveResults = $this -> GalaxyClusterRelationTag -> attachTags ( $user , $this -> id , $tags , $capture = $capture );
if ( ! $tagSaveResults ) {
$errors [] = __ ( 'Tags could not be saved' );
}
2020-05-29 10:02:17 +02:00
}
2020-06-29 09:10:28 +02:00
} else {
foreach ( $this -> validationErrors as $validationError ) {
$errors [] = $validationError [ 0 ];
}
2020-05-07 16:17:44 +02:00
}
2020-05-07 12:30:05 +02:00
}
2020-05-07 16:17:44 +02:00
return $errors ;
2020-05-07 12:30:05 +02:00
}
2020-05-07 15:15:14 +02:00
2020-05-29 08:56:29 +02:00
public function editRelation ( $user , $relation , $fieldList = array (), $capture = false )
2020-05-07 15:15:14 +02:00
{
$this -> SharingGroup = ClassRegistry :: init ( 'SharingGroup' );
$errors = array ();
if ( ! $user [ 'Role' ][ 'perm_galaxy_editor' ] && ! $user [ 'Role' ][ 'perm_site_admin' ]) {
$errors [] = __ ( 'Incorrect permission' );
}
if ( isset ( $relation [ 'GalaxyClusterRelation' ][ 'id' ])) {
$existingRelation = $this -> find ( 'first' , array ( 'conditions' => array ( 'GalaxyClusterRelation.id' => $relation [ 'GalaxyClusterRelation' ][ 'id' ])));
} else {
$errors [] = __ ( 'UUID not provided' );
}
if ( empty ( $existingRelation )) {
$errors [] = __ ( 'Unkown ID' );
} else {
2020-05-25 10:04:07 +02:00
$options = array ( 'conditions' => array (
2020-05-25 16:10:00 +02:00
'uuid' => $relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_uuid' ]
2020-05-25 10:04:07 +02:00
));
$cluster = $this -> SourceCluster -> fetchGalaxyClusters ( $user , $options );
if ( empty ( $cluster )) {
2020-05-25 16:10:00 +02:00
$errors [] = __ ( 'Invalid source galaxy cluster' );
2020-05-07 15:15:14 +02:00
}
2020-05-25 10:04:07 +02:00
$cluster = $cluster [ 0 ];
2020-05-07 15:15:14 +02:00
$relation [ 'GalaxyClusterRelation' ][ 'id' ] = $existingRelation [ 'GalaxyClusterRelation' ][ 'id' ];
2020-05-25 16:10:00 +02:00
$relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_id' ] = $cluster [ 'SourceCluster' ][ 'id' ];
$relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_uuid' ] = $cluster [ 'SourceCluster' ][ 'uuid' ];
2020-05-25 10:04:07 +02:00
if ( isset ( $relation [ 'GalaxyClusterRelation' ][ 'distribution' ]) && $relation [ 'GalaxyClusterRelation' ][ 'distribution' ] == 4 && ! $this -> SharingGroup -> checkIfAuthorised ( $user , $relation [ 'GalaxyClusterRelation' ][ 'sharing_group_id' ])) {
$errors [] = array ( __ ( 'Galaxy Cluster Relation could not be saved: The user has to have access to the sharing group in order to be able to edit it.' ));
}
2020-05-25 16:10:00 +02:00
if ( $cluster [ 'SourceCluster' ][ 'org_id' ] != $user [ 'org_id' ] && ! $user [ 'Role' ][ 'perm_site_admin' ]) {
$errors [] = array ( __ ( 'Relations can only be created by cluster\'s owner organisation' ));
}
2020-05-07 15:15:14 +02:00
if ( empty ( $errors )) {
2020-05-25 16:10:00 +02:00
$targetCluster = $this -> TargetCluster -> fetchGalaxyClusters ( $user , array ( 'conditions' => array ( 'uuid' => $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ])));
if ( empty ( $targetCluster )) { // do not save the relation if referenced cluster does not exists
$errors [] = array ( __ ( 'Invalid referenced galaxy cluster' ));
} else {
$targetCluster = $targetCluster [ 0 ];
$relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_id' ] = $targetCluster [ 'TargetCluster' ][ 'id' ];
$relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ] = $targetCluster [ 'TargetCluster' ][ 'uuid' ];
$relation [ 'GalaxyClusterRelation' ][ 'default' ] = false ;
if ( empty ( $fieldList )) {
$fieldList = array ( 'galaxy_cluster_id' , 'galaxy_cluster_uuid' , 'referenced_galaxy_cluster_id' , 'referenced_galaxy_cluster_uuid' , 'referenced_galaxy_cluster_type' , 'distribution' , 'sharing_group_id' , 'default' );
}
$saveSuccess = $this -> save ( $relation , array ( 'fieldList' => $fieldList ));
if ( ! $saveSuccess ) {
foreach ( $this -> validationErrors as $validationError ) {
$errors [] = $validationError [ 0 ];
}
2020-05-29 08:56:29 +02:00
} else {
$this -> GalaxyClusterRelationTag -> deleteAll ( array ( 'GalaxyClusterRelationTag.galaxy_cluster_relation_id' => $relation [ 'GalaxyClusterRelation' ][ 'id' ]));
$this -> GalaxyClusterRelationTag -> attachTags ( $user , $relation [ 'GalaxyClusterRelation' ][ 'id' ], $relation [ 'GalaxyClusterRelation' ][ 'tags' ], $capture = $capture );
2020-05-07 15:15:14 +02:00
}
}
}
}
return $errors ;
}
2020-05-20 10:33:33 +02:00
/**
* Gets a relation then save it .
*
* @ param $user
* @ param array $relation Relation to be saved
* @ param bool $fromPull If the current capture is performed from a PULL sync
* @ return array
*/
2020-05-25 10:04:07 +02:00
public function captureRelations ( $user , $cluster , $relations , $fromPull = false )
2020-05-20 10:33:33 +02:00
{
$results = array ( 'success' => false , 'imported' => 0 , 'failed' => 0 );
$this -> Log = ClassRegistry :: init ( 'Log' );
2020-05-25 10:04:07 +02:00
$clusterUuid = $cluster [ 'GalaxyCluster' ][ 'uuid' ];
2020-05-20 10:33:33 +02:00
foreach ( $relations as $k => $relation ) {
if ( ! isset ( $relation [ 'GalaxyClusterRelation' ])) {
$relation = array ( 'GalaxyClusterRelation' => $relation );
}
2020-05-25 10:04:07 +02:00
$relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_uuid' ] = $clusterUuid ;
$relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_id' ] = $cluster [ 'GalaxyCluster' ][ 'id' ];
if ( empty ( $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ])) {
2020-06-08 11:10:59 +02:00
$this -> Log -> createLogEntry ( $user , 'captureRelations' , 'GalaxyClusterRelation' , 0 , __ ( 'No referenced cluster UUID provided' ), __ ( 'relation for cluster (%s)' , $clusterUuid ));
2020-05-20 10:33:33 +02:00
$results [ 'failed' ] ++ ;
continue ;
} else {
$options = array (
'conditions' => array (
2020-05-25 10:04:07 +02:00
'uuid' => $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ],
),
'fields' => array (
'id' , 'uuid' ,
2020-05-20 10:33:33 +02:00
)
);
2020-05-25 10:04:07 +02:00
$referencedCluster = $this -> SourceCluster -> fetchGalaxyClusters ( $user , $options );
2020-05-20 10:33:33 +02:00
if ( empty ( $referencedCluster )) {
2020-06-08 11:10:59 +02:00
$this -> Log -> createLogEntry ( $user , 'captureRelations' , 'GalaxyClusterRelation' , 0 , __ ( 'Referenced cluster not found' ), __ ( 'relation to (%s) for cluster (%s)' , $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ], $clusterUuid ));
2020-06-10 16:45:05 +02:00
$relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_id' ] = 0 ;
2020-05-20 10:33:33 +02:00
} else {
$referencedCluster = $referencedCluster [ 0 ];
2020-05-25 10:04:07 +02:00
$relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_id' ] = $referencedCluster [ 'SourceCluster' ][ 'id' ];
2020-05-20 10:33:33 +02:00
}
}
2020-05-25 10:04:07 +02:00
if ( $cluster [ 'GalaxyCluster' ][ 'orgc_id' ] != $user [ 'org_id' ] && ! $user [ 'Role' ][ 'perm_sync' ] && ! $user [ 'Role' ][ 'perm_site_admin' ]) {
2020-06-15 15:07:13 +02:00
$cluster [ 'GalaxyCluster' ][ 'orgc_id' ] != $user [ 'org_id' ]; // Only sync user can create galaxy on behalf of other users
2020-05-20 10:33:33 +02:00
}
2020-05-29 10:02:17 +02:00
$existingRelation = $this -> find ( 'first' , array ( 'conditions' => array (
'GalaxyClusterRelation.galaxy_cluster_uuid' => $relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_uuid' ],
'GalaxyClusterRelation.referenced_galaxy_cluster_uuid' => $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ],
'GalaxyClusterRelation.referenced_galaxy_cluster_type' => $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_type' ],
)));
if ( ! empty ( $existingRelation )) {
if ( ! $fromPull ) {
2020-06-08 11:10:59 +02:00
$this -> Log -> createLogEntry ( $user , 'captureRelations' , 'GalaxyClusterRelation' , 0 , __ ( 'Relation already exists' ), __ ( 'relation to (%s) for cluster (%s)' , $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ], $clusterUuid ));
2020-05-29 10:02:17 +02:00
$results [ 'failed' ] ++ ;
continue ;
} else {
$relation [ 'GalaxyClusterRelation' ][ 'id' ] = $existingRelation [ 'GalaxyClusterRelation' ][ 'id' ];
}
} else {
$this -> create ();
}
2020-05-25 10:04:07 +02:00
$this -> Event = ClassRegistry :: init ( 'Event' );
if ( isset ( $relation [ 'GalaxyClusterRelation' ][ 'distribution' ]) && $relation [ 'GalaxyClusterRelation' ][ 'distribution' ] == 4 ) {
$relation [ 'GalaxyClusterRelation' ] = $this -> Event -> __captureSGForElement ( $relation [ 'GalaxyClusterRelation' ], $user );
2020-05-20 10:33:33 +02:00
}
$saveSuccess = $this -> save ( $relation );
if ( $saveSuccess ) {
$results [ 'imported' ] ++ ;
2020-06-08 12:14:56 +02:00
$modelKey = false ;
if ( ! empty ( $relation [ 'GalaxyClusterRelation' ][ 'GalaxyClusterRelationTag' ])) {
$modelKey = 'GalaxyClusterRelationTag' ;
} elseif ( ! empty ( $relation [ 'GalaxyClusterRelation' ][ 'Tag' ])) {
$modelKey = 'Tag' ;
}
if ( $modelKey !== false ) {
$tagNames = Hash :: extract ( $relation [ 'GalaxyClusterRelation' ][ $modelKey ], '{n}.name' );
2020-05-29 10:02:17 +02:00
// Here we only attach tags. If they were removed at some point it's not taken into account. Since we don't have tag soft-deletion, tags added by users will be kept.
2020-05-29 08:56:29 +02:00
$this -> GalaxyClusterRelationTag -> attachTags ( $user , $this -> id , $tagNames , $capture = true );
2020-05-25 10:04:07 +02:00
}
2020-05-20 10:33:33 +02:00
} else {
$results [ 'failed' ] ++ ;
foreach ( $this -> validationErrors as $validationError ) {
}
}
}
$results [ 'success' ] = $results [ 'imported' ] > 0 ;
return $results ;
}
2020-05-25 17:02:26 +02:00
private function syncUUIDsAndIDs ( $user , $relation )
{
$options = array ( 'conditions' => array (
'uuid' => $relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_uuid' ]
));
$sourceCluster = $this -> SourceCluster -> fetchGalaxyClusters ( $user , $options );
if ( ! empty ( $sourceCluster )) {
$sourceCluster = $sourceCluster [ 0 ];
$relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_id' ] = $sourceCluster [ 'SourceCluster' ][ 'id' ];
$relation [ 'GalaxyClusterRelation' ][ 'galaxy_cluster_uuid' ] = $sourceCluster [ 'SourceCluster' ][ 'uuid' ];
}
$options = array ( 'conditions' => array (
'uuid' => $relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ]
));
$targetCluster = $this -> TargetCluster -> fetchGalaxyClusters ( $user , $options );
if ( ! empty ( $targetCluster )) {
$targetCluster = $targetCluster [ 0 ];
$relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_id' ] = $targetCluster [ 'TargetCluster' ][ 'id' ];
$relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_uuid' ] = $targetCluster [ 'TargetCluster' ][ 'uuid' ];
2020-06-09 12:18:58 +02:00
} else {
$relation [ 'GalaxyClusterRelation' ][ 'referenced_galaxy_cluster_id' ] = 0 ;
2020-05-25 17:02:26 +02:00
}
return $relation ;
}
2020-05-06 07:59:57 +02:00
}