Namespace: OpenEdge.DataAdmin.Binding
Class
TenantGroupContext
Parent classes:
Inherits: OpenEdge.DataAdmin.Binding.DataAdminContext
Implements: OpenEdge.DataAdmin.Binding.IDataAdminContext

/* Copyright (c) 2010-2013 by progress Software Corporation
/*
/* all rights reserved. no part of this program or document
/* may be reproduced in any form or by any means without
/* permission in writing from progress Software Corporation.
File:TenantGroupContext
Author(s):hdaniels
Created:2010




Method Summary
Options Name Purpose
Allocate (character)
LOGICAL CanFind (character)
LOGICAL CanFind (integer)
CopyChildTable (character, handle)
CopyTable (IDataAdminModel)
CopyTable (table)
OpenEdge.DataAdmin.IDataAdminCollection CreateCollection (character, FilteredContext)
OpenEdge.DataAdmin.IDataAdminCollection CreateCollection (IDataAdminContext)
OpenEdge.DataAdmin.IDataAdminElement CreateEntity (IRequestInfo)
OpenEdge.DataAdmin.Binding.Query.FilteredContext CreateFilteredContext (IRow, IRequestInfo)
HANDLE CreateImportTable (character)
CreatePartitionAfterQuery (handle)
OpenEdge.DataAdmin.Message.IFetchRequest CreatePartitionRefreshRequest (character)
CreateRow (IDataAdminElement) /* the default syserror has all info */
CreateRow (ITenantGroup)
DataRefreshed (IFetchResponse)
DeletePartitionAfterQuery ()
LOGICAL DeserializeRow (handle, log)
LOGICAL Find (character)
LOGICAL Find (integer)
CHARACTER FindExpression (character)
CHARACTER FindExpression (integer) /*** 11.0 September 20, 2011 - remove ... /* Called from merge with the changes returned from server to keep track of which partitions that will need to be refreshed. */ method private logical CreatePartionRefreshIds (pdsChanged as handle): define variable hQuery as handle no-undo. define variable hBuffer as handle no-undo. define variable hBefore as handle no-undo. define variable lok as logical no-undo. define variable lRefresh as logical no-undo. define variable hPartition as handle no-undo. hbuffer = pdsChanged:get-buffer-handle ("ttTenantGroup"). create query hQuery. hquery:add-buffer (hbuffer). hQuery:query-prepare ("for each ttTenantGroup"). hquery:query-open(). hquery:get-first. loop: do while hbuffer:avail: if hbuffer:row-state = row-created then do transaction on error undo, leave loop: create ttGroupNameRequest. assign ttGroupNameRequest.Id = hBuffer::Id ttGroupNameRequest.ObjectType = hBuffer::ObjectType ttGroupNameRequest.ObjectNumber = hBuffer::ObjectNumber ttGroupNameRequest.Name = hBuffer::name. end. hQuery:get-next. lok = true. end. end method. method public logical HasPartitionChanges(): define variable hBuffer as handle no-undo. hbuffer = GetChild("partitions"):Tablehandle:default-buffer-handle. return hBuffer:before-buffer:table-handle:has-records. end method. method public logical NeedPartitionRefresh(): define variable lok as logical no-undo. return can-find(first ttGroupNameRequest). end method. method private logical EmptyPartitionRefresh(): empty temp-table ttGroupNameRequest. end method. method private void DeletePartitionsBeforeRequest (): define variable hQuery as handle no-undo. define variable hBuffer as handle no-undo. create query hQuery. /* now workaround the fact that fill cannot replace (even if it should? ) */ hbuffer = GetChild("partitions"):Tablehandle:default-buffer-handle. hquery:set-buffers (buffer ttGroupNameRequest:handle). hquery:add-buffer (hbuffer). hQuery:query-prepare ("for each ttGroupNameRequest, each ttPartition where ttGroupNameRequest.name = ttPartition.TenantGroupname"). hquery:query-open(). hquery:get-first. /* hBuffer:table-handle:tracking-changes = false.*/ do while hbuffer:avail: hBuffer:buffer-delete (). hQuery:get-next. end. /* hBuffer:table-handle:tracking-changes = true.*/ delete object hQuery. end method. method private IFetchRequest CreatePartitionRefreshRequest (): define variable tree as IContextTree no-undo. define variable msg as IFetchRequest no-undo. tree = new ContextTree(). tree:Parse = true. tree:SetHandle("requests",buffer ttGroupNameRequest:handle). GetChild("partitions"):AddTableTo(tree). msg = new FetchRequest("Partition",Id,tree:GetReadHandle()). return msg. end method. method override public void MergeChanges( pResponse as ISaveRequest ): define variable lok as logical no-undo. define variable msg as IFetchRequest no-undo. if not NeedPartitionRefresh() then do: CreatePartionRefreshIds(pResponse:DataHandle). end. super:MergeChanges(pResponse). if (not HasPartitionChanges()) and NeedPartitionRefresh() then do: DeletePartitionsBeforeRequest(). msg = CreatePartitionRefreshRequest(). msg:UseReplaceOnClient = false. FetchData(msg). EmptyPartitionRefresh(). end. end method. */
CHARACTER GetChildQuery (IRow)
CHARACTER GetCreateError (ITenantGroup)
CHARACTER GetJoinFields (character)
OpenEdge.DataAdmin.Binding.IDataAdminModel GetNamedChild (character) /* support many-to-many to tenants (tenants as child) */
OpenEdge.DataAdmin.Binding.PartitionContext GetPartitionContext ()
HANDLE GetQueryHandles (character)
OpenEdge.DataAdmin.Message.IFetchRequest GetRequest () /* method public ISaveRequest GetCreateRequest(): define variable hchanges as handle no-undo. define variable savemsg as ISaveRequest no-undo. SaveDataset = CreateDataset("tenantGroupMembers"). hchanges = GetChanges(SaveDataset). savemsg = new SaveRequest(Name,Id,hchanges). /* mCreate = true.*/ return savemsg. end method. */
CHARACTER GetServerChildQuery (IRow)
initChildren ()
initChildren (IContextScope)
initChildren (IMultiTenantScope)
HANDLE InitDataset () /* temporary until all sub classes are using createDataset */
MergeChanges (ISaveRequest) /** override to refresh partitions for create */
LOGICAL PartitionsNeedRefresh (character) /** called from merge to check if allocationstate of a table changed */
LOGICAL RefreshPartitions (handle)
SerializeRow (handle)
ValidateGroup (ITenantGroup)
ValueChanged (character, character, character)

Constructor Summary
Options Name Purpose
TenantGroupContext ()
TenantGroupContext (IMultiTenantScope)

Property Summary
Options Name Purpose
INTEGER Count
CHARACTER KeyFields
HANDLE TableHandle


Method Detail
Top

Allocate (character)

Parameters:
pcGroup CHARACTER
Top

LOGICAL CanFind (character)

Parameters:
name CHARACTER
Returns LOGICAL
Top

LOGICAL CanFind (integer)

Parameters:
id INTEGER
Returns LOGICAL
Top

CopyChildTable (character, handle)

Parameters:
cname CHARACTER
ht HANDLE
Top

CopyTable (IDataAdminModel)

Parameters:
cntxt OpenEdge.DataAdmin.Binding.IDataAdminModel
Top

CopyTable (table)

Parameters:
copytable TABLE
Top

OpenEdge.DataAdmin.IDataAdminCollection CreateCollection (character, FilteredContext)

Parameters:
pparent CHARACTER
pcntxt OpenEdge.DataAdmin.Binding.Query.FilteredContext
Returns OpenEdge.DataAdmin.IDataAdminCollection
Top

OpenEdge.DataAdmin.IDataAdminCollection CreateCollection (IDataAdminContext)

Parameters:
cntxt OpenEdge.DataAdmin.Binding.IDataAdminContext
Returns OpenEdge.DataAdmin.IDataAdminCollection
Top

OpenEdge.DataAdmin.IDataAdminElement CreateEntity (IRequestInfo)

Parameters:
preq OpenEdge.DataAdmin.IRequestInfo
Returns OpenEdge.DataAdmin.IDataAdminElement
Top

OpenEdge.DataAdmin.Binding.Query.FilteredContext CreateFilteredContext (IRow, IRequestInfo)

Parameters:
pparent OpenEdge.DataAdmin.Binding.IRow
pReq OpenEdge.DataAdmin.IRequestInfo
Returns OpenEdge.DataAdmin.Binding.Query.FilteredContext
Top

HANDLE CreateImportTable (character)

Parameters:
cname CHARACTER
Returns HANDLE
Top

CreatePartitionAfterQuery (handle)

Parameters:
pbufferHandle HANDLE
Top

OpenEdge.DataAdmin.Message.IFetchRequest CreatePartitionRefreshRequest (character)

Parameters:
pcGroup CHARACTER
Returns OpenEdge.DataAdmin.Message.IFetchRequest
Top

CreateRow (IDataAdminElement)

/* the default syserror has all info
Parameters:
entity OpenEdge.DataAdmin.IDataAdminElement
Top

CreateRow (ITenantGroup)

Parameters:
tenantGroup OpenEdge.DataAdmin.ITenantGroup
Top

DataRefreshed (IFetchResponse)

Parameters:
presponse OpenEdge.DataAdmin.Message.IFetchResponse
Top

DeletePartitionAfterQuery ()

Top

LOGICAL DeserializeRow (handle, log)

Parameters:
phStream HANDLE
plReplace LOGICAL
Returns LOGICAL
Top

LOGICAL Find (character)

Parameters:
name CHARACTER
Returns LOGICAL
Top

LOGICAL Find (integer)

Parameters:
id INTEGER
Returns LOGICAL
Top

CHARACTER FindExpression (character)

Parameters:
c CHARACTER
Returns CHARACTER
Top

CHARACTER FindExpression (integer)

/* Called from merge with the changes returned from server to keep track of
which partitions that will need to be refreshed.
method private logical CreatePartionRefreshIds (pdsChanged as handle):
define variable hQuery as handle no-undo.
define variable hBuffer as handle no-undo.
define variable hBefore as handle no-undo.
define variable lok as logical no-undo.
define variable lRefresh as logical no-undo.
define variable hPartition as handle no-undo.
hbuffer = pdsChanged:get-buffer-handle ("ttTenantGroup").
create query hQuery.
hquery:add-buffer add-buffer (hbuffer).
hQuery:query-prepare query-prepare ("for each ttTenantGroup").
hquery:query-open(). query-open().
hquery:get-first. get-first.
loop:
do while hbuffer:avail:
if hbuffer:row-state = row-created then
do transaction on error undo, leave loop:
create ttGroupNameRequest.
assign
ttGroupNameRequest.Id = hBuffer::Id
ttGroupNameRequest.ObjectType = hBuffer::ObjectType
ttGroupNameRequest.ObjectNumber = hBuffer::ObjectNumber
ttGroupNameRequest.Name = hBuffer::name.
end.
hQuery:get-next. get-next.
lok = true.
end.
end method.
method public logical HasPartitionChanges():
define variable hBuffer as handle no-undo.
hbuffer = GetChild("partitions"):Tablehandle:default-buffer-handle.
return hBuffer:before-buffer:table-handle:has-records.
end method.
method public logical NeedPartitionRefresh():
define variable lok as logical no-undo.
return can-find(first ttGroupNameRequest).
end method.
method private logical EmptyPartitionRefresh():
empty temp-table ttGroupNameRequest.
end method.
method private void DeletePartitionsBeforeRequest ():
define variable hQuery as handle no-undo.
define variable hBuffer as handle no-undo.
create query hQuery.
/* now workaround the fact that fill cannot replace (even if it should? )
hbuffer = GetChild("partitions"):Tablehandle:default-buffer-handle.
hquery:set-buffers set-buffers (buffer ttGroupNameRequest:handle).
hquery:add-buffer add-buffer (hbuffer).
hQuery:query-prepare query-prepare ("for each ttGroupNameRequest, each ttPartition where ttGroupNameRequest.name = ttPartition.TenantGroupname").
hquery:query-open(). query-open().
hquery:get-first. get-first.
/* hBuffer:table-handle:tracking-changes = false.
do while hbuffer:avail:
hBuffer:buffer-delete buffer-delete ().
hQuery:get-next. get-next.
end.
/* hBuffer:table-handle:tracking-changes = true.
delete object hQuery.
end method.
method private IFetchRequest CreatePartitionRefreshRequest ():
define variable tree as IContextTree no-undo.
define variable msg as IFetchRequest no-undo.
tree = new ContextTree().
tree:Parse Parse = true.
tree:SetHandle("requests",buffer SetHandle("requests",buffer ttGroupNameRequest:handle).
GetChild("partitions"):AddTableTo(tree). AddTableTo(tree).
msg = new FetchRequest("Partition",Id,tree:GetReadHandle()).
return msg.
end method.
method override public void MergeChanges( pResponse as ISaveRequest ):
define variable lok as logical no-undo.
define variable msg as IFetchRequest no-undo.
if not NeedPartitionRefresh() then
do:
CreatePartionRefreshIds(pResponse:DataHandle). DataHandle).
end.
super:MergeChanges(pResponse). MergeChanges(pResponse).
if (not HasPartitionChanges()) and NeedPartitionRefresh() then
do:
DeletePartitionsBeforeRequest().
msg = CreatePartitionRefreshRequest().
msg:UseReplaceOnClient UseReplaceOnClient = false.
FetchData(msg).
EmptyPartitionRefresh().
end.
end method.
Parameters:
i INTEGER
Returns CHARACTER
Top

CHARACTER GetChildQuery (IRow)

Parameters:
pParent OpenEdge.DataAdmin.Binding.IRow
Returns CHARACTER
Top

CHARACTER GetCreateError (ITenantGroup)

Parameters:
tenantGroup OpenEdge.DataAdmin.ITenantGroup
Returns CHARACTER
Top

CHARACTER GetJoinFields (character)

Parameters:
parentid CHARACTER
Returns CHARACTER
Top

OpenEdge.DataAdmin.Binding.IDataAdminModel GetNamedChild (character)

/* support many-to-many to tenants (tenants as child)
Parameters:
pname CHARACTER
Returns OpenEdge.DataAdmin.Binding.IDataAdminModel
Top

OpenEdge.DataAdmin.Binding.PartitionContext GetPartitionContext ()

Returns OpenEdge.DataAdmin.Binding.PartitionContext
Top

HANDLE GetQueryHandles (character)

Parameters:
pcParent CHARACTER
Returns HANDLE
Top

OpenEdge.DataAdmin.Message.IFetchRequest GetRequest ()

/*
method public ISaveRequest GetCreateRequest():
define variable hchanges as handle no-undo.
define variable savemsg as ISaveRequest no-undo.
SaveDataset = CreateDataset("tenantGroupMembers").
hchanges = GetChanges(SaveDataset).
savemsg = new SaveRequest(Name,Id,hchanges).
/* mCreate = true.
return savemsg.
end method.
Returns OpenEdge.DataAdmin.Message.IFetchRequest
Top

CHARACTER GetServerChildQuery (IRow)

Parameters:
pParent OpenEdge.DataAdmin.Binding.IRow
Returns CHARACTER
Top

initChildren ()

Top

initChildren (IContextScope)

Parameters:
pScope OpenEdge.DataAdmin.Binding.Factory.IContextScope
Top

initChildren (IMultiTenantScope)

Parameters:
pScope OpenEdge.DataAdmin.Binding.Factory.IMultiTenantScope
Top

HANDLE InitDataset ()

/* temporary until all sub classes are using createDataset
Returns HANDLE
Top

MergeChanges (ISaveRequest)

Purpose: override to refresh partitions for create
Parameters:
pResponse OpenEdge.DataAdmin.Message.ISaveRequest
Top

LOGICAL PartitionsNeedRefresh (character)

Purpose: called from merge to check if allocationstate of a table changed
Parameters:
pcGroup CHARACTER
Returns LOGICAL
Top

LOGICAL RefreshPartitions (handle)

Parameters:
pdsChanged HANDLE
Returns LOGICAL
Top

SerializeRow (handle)

Parameters:
phStream HANDLE
Top

ValidateGroup (ITenantGroup)

Parameters:
newgroup OpenEdge.DataAdmin.ITenantGroup
Top

ValueChanged (character, character, character)

Parameters:
pFieldName CHARACTER
pcOldValue CHARACTER
pNewValue CHARACTER


Constructor Detail
Top

TenantGroupContext ()

Top

TenantGroupContext (IMultiTenantScope)

Parameters:
pScope OpenEdge.DataAdmin.Binding.Factory.IMultiTenantScope


Property Detail
Top

INTEGER Count

Returns INTEGER
Top

CHARACTER KeyFields

Returns CHARACTER
Top

HANDLE TableHandle

Returns HANDLE


Copyright © 2022 Progress Software Corporation. All rights Reserved.

Progress® OpenEdge® Release 11.7.15