Solstice::Group::Remote - Model of groups who sync from a remote source.


Solstice documentation  | view source Contained in the Solstice distribution.

Index


NAME

Top

Solstice::Group::Remote - Model of groups who sync from a remote source.

SYNOPSIS

Top

DESCRIPTION

Top

Export

No symbols exported.

Methods

new($input)
clone() =cut

sub clone { my $self = shift; cluck "clone(): Not implemented"; return FAIL; }

delete() =cut

sub delete { my $self = shift; cluck "delete(): Not implemented"; return FAIL; }

reconcile() =cut

sub reconcile { my $self = shift; my $list = shift;

    unless ($self->isValidList($list)) {
        cluck 'reconcile(): requires a Solstice::List';
        return FAIL;
    }

    $self->SUPER::removeAllMembers();

    my $iterator = $list->iterator();
    while ($iterator->hasNext()) {
        return FALSE unless $self->SUPER::addMember($iterator->next());
    }

    $self->{'_is_reconciliation'} = TRUE;
    $self->{'_tainted_members'}   = TRUE;

    # Make sure we don't initialize group membership on store, otherwise
    # people who leave the remote group won't actually leave.
    $self->{'_initialized_members'} = TRUE;
    return SUCCESS;
}

store() =cut

sub store { my $self = shift;

    return SUCCESS unless $self->{'_tainted_members'};

    # Not sure this is needed if we're tainted...
    $self->_initializeMembers() unless $self->{'_initialized_members'};

    my $db = Solstice::Database->new();    
    my $config = Solstice::Configure->new();
    my $db_name = $config->getDBName();

    my $id = $self->getID();
    if (defined $id) {
        if ($self->{'_is_reconciliation'}) {
            $db->writeQuery('UPDATE '.$db_name.'.RemoteGroup SET date_reconciled = NOW() WHERE remote_group_id = ?',$id);
            $self->{'_is_reconciliation'} = FALSE;
        }
    } else {
        $db->readQuery('SELECT remote_group_source_id FROM '.$db_name.'.RemoteGroupSource WHERE package = ?',ref($self));
        my $remote_source_id = $db->fetchRow()->{'remote_group_source_id'}; 

        my $remote_key = $self->getRemoteKey();

        $db->readQuery('SELECT remote_group_id from '.$db_name.'.RemoteGroup where remote_key=? AND remote_group_source_id=?',$remote_key, $remote_source_id);

        $id = $db->fetchRow()->{'remote_group_id'};

        unless (defined $id) {
            my $name = $self->getName();
            my ($date_created, $date_modified);
            $db->writeQuery('INSERT INTO '.$db_name.'.RemoteGroup (remote_group_id, remote_group_source_id, remote_key, name, date_created, date_modified) VALUES (NULL,?,?,?, NOW(),NOW())', $remote_source_id, $remote_key, $name,);

            $id = $db->getLastInsertID();
            $db->readQuery('SELECT date_created, date_modified FROM '.$db_name.'.RemoteGroup WHERE remote_group_id=?', $id);

            my $data_ref = $db->fetchRow();
            $self->_setCreationDate(Solstice::DateTime->new($data_ref->{'date_created'}));
            $self->_setModificationDate(Solstice::DateTime->new($data_ref->{'date_modified'}));
        }
        $self->_setID($id);
    }

    my $person_insert = join ',', map { "(NULL, $id, $_)" } keys %{$self->{'_member_people'}};

    $db->writeQuery('DELETE FROM '.$db_name.'.PeopleInRemoteGroup WHERE remote_group_id = ?',$id);
    if ($person_insert) {
        $db->writeQuery('INSERT INTO '.$db_name.'.PeopleInRemoteGroup VALUES '.$person_insert);
    }

    $self->{'_tainted_members'} = FALSE;
    return SUCCESS;
}

getOwners() =cut

sub getOwners { my $self = shift; cluck "getOwners(): Not implemented"; return Solstice::List->new(); }

addOwner($person) =cut

sub addOwner { my $self = shift; cluck "addOwner(): Not implemented"; return FAIL; }

removeOwner($person) =cut

sub removeOwner { my $self = shift; cluck "removeOwner(): Not implemented"; return FAIL; }

isOwner($person) =cut

sub isOwner { my $self = shift; #there are currently no owners to remote groups return FAIL; }

addMember($person) =cut

sub addMember { my $self = shift; cluck "addMember(): Not implemented"; return FAIL; }

addMembers($list) =cut

sub addMembers { my $self = shift; cluck "addMembers(): Not implemented"; return FAIL; }

removeMember($person) =cut

sub removeMember { my $self = shift; cluck "removeMember(): Not implemented"; return FAIL; }

removeMembers($list) =cut

sub removeMembers { my $self = shift; cluck "removeMember(): Not implemented"; return FAIL; }

removeAllMembers($list) =cut

sub removeAllMembers { my $self = shift; cluck "removeAllMembers(): Not implemented"; return FAIL; }

isMemberGroup($group) =cut

sub isMemberGroup { return FALSE; }

getMemberGroups() =cut

sub getMemberGroups { my $self = shift; cluck "getMemberGroups(): Not implemented"; return Solstice::List->new(); }

addMemberGroup($group) =cut

sub addMemberGroup { my $self = shift; cluck "addMemberGroup(): Not implemented"; return FAIL; }

removeMemberGroup($group) =cut

sub removeMemberGroup { my $self = shift; cluck "removeMemberGroup(): Not implemented"; return FAIL; }

isRemoteMemberGroup($group) =cut

sub isRemoteMemberGroup { my $self = shift; cluck "isRemoteMemberGroup(): Not implemented"; return FALSE; }

getRemoteGroups() =cut

sub getRemoteGroups { my $self = shift; cluck "getRemoteGroups(): Not implemented"; return Solstice::List->new(); }

addRemoteGroup($group) =cut

sub addRemoteGroup { my $self = shift; cluck "addRemoteGroup(): Not implemented"; return FAIL; }

removeRemoteGroup($group) =cut

sub removeRemoteGroup { my $self = shift; cluck "addRemoteGroup(): Not implemented"; return FAIL; }

getSubgroups() =cut

sub getSubgroups { my $self = shift; cluck "getSubgroups(): Not implemented"; return FAIL; }

addSubgroup($subgroup)
removeSubgroup($subgroup) =cut

sub removeSubgroup { my $self = shift; cluck "removeSubgroup(): Not implemented"; return FAIL; }

getSubgroupCount() =cut

sub getSubgroupCount { my $self = shift; cluck "getSubgroupCount(): Not implemented"; return 0; }

Private Methods

_initMin($group_id)

Initializes the minimum amount of data about the group as it can. Loads no member groups, subgroups, people, or class lists.

_initFromHash($hash_ref)

Does a minimal initialization, with data from an outside source.

_initializeMembers()

Goes to the data store to retrive the list of members for this group.

_initializeOwners() =cut

sub _initializeOwners { return TRUE; }

_initializeMemberGroups() =cut

sub _initializeMemberGroups { my $self = shift; $self->{'_member_groups'} = {}; return TRUE; }

_initializeRemoteGroups() =cut

sub _initializeRemoteGroups { my $self = shift; $self->{'_remote_groups'} = {}; return TRUE; }

_initializeSubgroups()
_getAllMembers($seen_group_hash)
_populateDBMemberHash(\%member_hash)
_getAccessorDefinition()

AUTHOR

Top

Catalyst Group, <catalyst@u.washington.edu>

VERSION

Top

$Revision: $

COPYRIGHT

Top


Solstice documentation  | view source Contained in the Solstice distribution.