Cloning a member Integer...
Hi all experts, if I have a class like MyClass below, I understand from what I've read, that to achieve deep copy, I must clone all members that are not primitives, while the primitives get cloned automatically by Object.clone().
Fine so long, I just make clone methods in the wrapped classes (like MyWrappedClass below) that are called from the top level class' clone. But what about members that are for example String or Integers?? Must I subclass the String and Integer classes to implement their clone method?? Seems lika a long way to go...
Very thankful for any help in resolving this issue/
AC
MyClass implements Cloneable{
int i; //automatically cloned by Object.clone
Integer integer; //How to clone this?
String string; //How to clone this?
MyWrappedClass coolClass;//easy to clone
public Object clone(){
}
I must clone all members that are not
primitives, while the primitives get cloned
automatically by Object.clone().Object.clone() does a byte-level (for lack of a better term) copy of the object's data. That means that it copies all primitives, as you noted, but also copies all pointers. The cloned pointers will point to the same objects as the original object's pointers.
Objects such as Integer or String are immutable, meaning that you give them a value at construction, and cannot change that value. So, if you clone a pointer to an Integer, you have no worries that the value will change unexpectedly.
More complex objects, however, typically have getter and setter methods. For example, a HashMap can have objects added to and removed from it over its lifetime. If you clone an object that contains a HashMap, both the old and new object will point to the same HashMap.
However, the main reason that you use clone() is to make a snapshot of an object, which is then processed differently than the original object. You typically don't want these two streams of execution to see changes made by the other, and the only way to do this is to make a copy of the HashMap (as well as any other contained objects that can be modified).
I will note here, that I can probably count the number of times I've needed clone() on one hand. I would suggest that, before you implement it, you give some thought as to why you need a snapshot of your object, and whether there might not be a better alternative.
Similar Messages
-
Is it possible to open a form created with screen painter more than once?
I have created a form with the screen painter. In the screen painter the form is assigned a FormUID. Probably because this is done, it is impossible to open the form more than once??
Thanks,
Kind regardsHi J.
The answer is yes You just have to give your form a unique id.
1) Give your form in screen painter a name like BTWO_DYNAMIC_UID (just plain text).
2) Make sure your <i>FormType</i> and <i>appformnumber</i> have a unique number (i.e. 2000060001). You can do this in the xml source.
3) By loading your document replace the BTWO_DYNAMIC_UID with an unique id. I have a counter that's a member of my class and increase that number to get a unique id (BTWO_F_1, BTWO_F_2 etc)
I have added a code sample, SBOApplication is my SAP application object and mFormNumber is a member (integer) of my class.
<i>Succes d'r mee, en als 't nie lukt hoor ik het wel... ;)</i>
<b>Code (C#):</b>
// New xml document
XmlDocument oXmlDoc = new XmlDocument();
private Form LoadUniqueForm(string AMyFile)
// Define your path to
sPath = @"Forms" + AMyFile;
// Load the form
oXmlDoc.Load(sPath);
// Replace the string with an unique id
mFormNumber++;
string sXML = oXmlDoc.InnerXml.Replace("BTWO_DYNAMIC_UID", "BTWO_F_" + mFormNumber.ToString());
// load the XML file in SAP
SBOApplication.LoadBatchActions(ref sXML);
// Return the form
return SBOApplication.Forms.Item("BTWO_F_" + mFormNumber.ToString()); -
How to increase formUID to a form created with screen painter
Hi,
I've got a problem with my form. I created a form with screen painter but i can't succeed to increase my UID form.
For example, when i open my first form, the UID is always at FP_0.
My script:
private string FormUID = null;
public FP_Form(int NumInstance_)
this.NumInstance = NumInstance_;
this.FormUID = "FP" + NumInstance.ToString();
load();
oDBDataSource = oForm.DataSources.DBDataSources.Add(DBDataSourceTable);
SBO_Application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent);
private void SBO_Application_ItemEvent(string _FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
BubbleEvent = true;
try
if (_FormUID == this.FormUID) //here "_FormUID" is increased but "this.FormUID" is still = FP_0
switch (pVal.EventType)// selon le type d'action executée
case SAPbouiCOM.BoEventTypes.et_FORM_LOAD:
if (pVal.BeforeAction == true)
SAPbouiCOM.ComboBox List_reseau = (SAPbouiCOM.ComboBox)oForm.Items.Item("5").Specific;
List_reseau.ValidValues.Add("1", "test");
break;
case ...
break;
Please help.
Regards,
Zakia.Hi J.
The answer is yes You just have to give your form a unique id.
1) Give your form in screen painter a name like BTWO_DYNAMIC_UID (just plain text).
2) Make sure your <i>FormType</i> and <i>appformnumber</i> have a unique number (i.e. 2000060001). You can do this in the xml source.
3) By loading your document replace the BTWO_DYNAMIC_UID with an unique id. I have a counter that's a member of my class and increase that number to get a unique id (BTWO_F_1, BTWO_F_2 etc)
I have added a code sample, SBOApplication is my SAP application object and mFormNumber is a member (integer) of my class.
<i>Succes d'r mee, en als 't nie lukt hoor ik het wel... ;)</i>
<b>Code (C#):</b>
// New xml document
XmlDocument oXmlDoc = new XmlDocument();
private Form LoadUniqueForm(string AMyFile)
// Define your path to
sPath = @"Forms" + AMyFile;
// Load the form
oXmlDoc.Load(sPath);
// Replace the string with an unique id
mFormNumber++;
string sXML = oXmlDoc.InnerXml.Replace("BTWO_DYNAMIC_UID", "BTWO_F_" + mFormNumber.ToString());
// load the XML file in SAP
SBOApplication.LoadBatchActions(ref sXML);
// Return the form
return SBOApplication.Forms.Item("BTWO_F_" + mFormNumber.ToString()); -
Is this bad coding style?
I have come across a price- winning GUI library for java (JSuite from Infragistics).
A lot of high quality GUI- components... Now, I am trying to understand the code.
Here are three of the code- lines
if(m_iCurM > 0) iDay |= ((m_iCurY << 9) | ((m_iCurM - 1) << 5));
if(bar != 1000 || (r.width -= w0) < 2) return;
while(++i < m_days.size()) if((j = ((PVDay)m_days.elementAt(i)).m_id0) >= 0) return get(j);Its all like that! Short names, non- descriptive names, long lines and magic values.
If I wrote code like that, my boss would kill me.Well, I guess I should give you more that three lines...
and the m_ is not the problem! If someone adds information to the code, like m_... meaning this is a member, or m_i... meaning this is a member integer, that is all nice.
But, void drag(MouseEvent e)
PVDay d = null, d0 = (PVDay)e.getSource(), old = dayAt(m_z1);
Rectangle r = d0.getBounds();
int x = e.getX() + r.x, y = e.getY(), num = getNumberOfDays() + 1;
int i = num * getNumberOfWeeks();
while((d = dayAt(--i)) != null)
if(d.getBounds().contains(x, y + r.y)) break;
// 0x0000007f - ? ** (id for PVWeek)
// id of day under mouse
i = (d == null) ? 0 : (d.m_2 & 0x0000007f);the local identifiers d, d0, r, x and i could have longer and more descriptive names...
And the line while(++i < m_days.size()) if((j = ((PVDay)m_days.elementAt(i)).m_id0) >= 0) return get(j); is just the same aswhile(++i < m_days.size())
j = ((PVDay)m_days.elementAt(i)).m_id0;
if(j >= 0)
return get(j);
}, so why not use the later? It compiles to the same result!
And this is not obfuscated. This is the code they are selling. Its even commented (as you can see), and thats helping a little bit, but still!
And its not an inner loop heavy super-optimized algorithm. All the code is like this. Thousands of lines... -
Coherence Mbeans doesnt support weblogic standard
Hi,
According to weblogic standard, the mbeans should be called:
domain:Name=name,Type=type[,Location=serverName][,TypeOfParentMBean=NameOfParentMBean][,TypeOfParentMBean1=NameOfParentMBean1]...
The Mbeans I looked at use the type attribute instead of Type.
The code I use queries the server using "Type" and therefore I dont get as a result any of the coherence mbeans, just the weblogic ones.
What can I do about it? (the code is already deployed on mulitple customer sites)
Also, when I use the connection to query all mbeans for example:
mbeanServerConnection.queryNames(null, null);
I dont get back the coherence mbeans. is that because of the same problem?Hi,
Have you tried using an MBean Notification Listener? You can register for MBean events on MBeans that provide notifications. In this case we want to know when a Coherence MBean is regaitered so we can access it so you can listen to events on the JVM's own JMImplementation:type=MBeanServerDelegate MBean. Among other things, this MBean fires an event each time an MBean is registered.
Here is an example
final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
NotificationFilter filter = new NotificationFilter() {
@Override
public boolean isNotificationEnabled(Notification notification) {
return "JMX.mbean.registered".equals(notification.getType());
NotificationListener listener = new NotificationListener() {
@Override
public void handleNotification(Notification notification, Object handback) {
try {
ObjectName mBeanName = ((MBeanServerNotification) notification).getMBeanName();
if ("Node".equals(mBeanName.getKeyProperty("type"))) {
System.out.println("Node MBean registered " + mBeanName);
Integer member = (Integer) mBeanServer.getAttribute(mBeanName, "Id");
System.out.println("Node Member ID = " + member);
} catch (Exception e) {
e.printStackTrace();
mBeanServer.addNotificationListener(new ObjectName("JMImplementation:type=MBeanServerDelegate"), listener, filter, null);In the code above we create a NotificationFilter that will only pass MBean registration events. We create a listener that looks for MBean registrations where the "type" attribute of the MBean's ObjectName is "Node", i.e. we have a Coherence Node MBean registration. The listener then gets the Nodes member Id and prints it. You should be able to figure out from that how to do other things.
JK -
Difficulties cloning element data member
Hi,
I have a DataObject class that has a DOM Element as a data member (metadata). This class has a clone method that is meant to do the usual clone shenanigans but it is behaving strangely.
When I create a new DataObject, the data members of the calling DataObject are reset, as if it was calling the constructor on its self. Does this have anything to do with the use of the Element (maybe cloning it and not removing it from a Document) or have I forgot how to implement cloneable properly?
The first output shows the data members of the calling object prior to creating the cloned object. The second shows after and the third shows after setting the cloned object's members. I have a sneaking suspicion that I am just setting the calling object's members again.
Here's the code for the method and the output:
public Object clone(){
DataObject myDO;
Element newMeta = (Element)metadata.cloneNode(true); //copy metadata
byte[] pCopy = new byte[physicaldata.length];
System.arraycopy(physicaldata, 0, pCopy, 0, physicaldata.length); //copy physical data
System.out.println("this mdata exists 1: " + this.metadataExists());
System.out.println("this pdata exists 1: " + this.physicaldataExists());
myDO = new DataObject();
System.out.println("this mdata exists 2: " + this.metadataExists());
System.out.println("this pdata exists 2: " + this.physicaldataExists());
try{
myDO.setMetadata(newMeta);
}catch(DataObjectException d){
System.out.println("Metadata could not be set");
myDO.setPhysicaldata(pCopy);
System.out.println("this mdata exists 3: " + this.metadataExists());
System.out.println("this pdata exists 3: " + this.physicaldataExists());
return myDO;
System.out
this mdata exists 1: true
this pdata exists 1: true
this mdata exists 2: false
this pdata exists 2: false
this mdata exists 3: true
this pdata exists 3: true
Any ideas would be appreciated. Cheers.
Brent.I have a feeling that naming my data members as static may have something to do with this.
If so, I will later invite people to shoot me in the head. -
Cloning VMs from a single VM which is Member of Domain
Hello There,
I have a VM which is got XenApp application server role and we have done lot of testing for each and every applicaiton which will be published through it, now this VM is completely ready.
We would like to clone this VM and create multiple XenApp Servers instead of going through the whole testing procedure for each application.
We use VMM2012 and HyperV 2008R2 what is the best way of cloning these machines because when we clone once machine it will have the same computer name and all unique IDs associated with it and it is also part of domain.
So what should we do in this scenario if we want to create multiple clones of the same machine, please suggest.
Regards,
Maqsood
Maqsood Mohammed Senior Systems Engineer MCITP-Enterprise Admin & ITILv3 Foundation CertifiedHello There,
I have found an article for syspreping the XenApp server if we use this there is no need to disjoin the server domain and i can still clone the VMs from it after sysprep.
http://support.citrix.com/proddocs/topic/xenapp5fp-w2k8/ps-install-config-clone-task-v2.html
Regards,
Maqsood
Maqsood Mohammed Senior Systems Engineer MCITP-Enterprise Admin & ITILv3 Foundation Certified -
How do I set a unique texture for each cloned 3D model in Director?
Hi,
I am using a 3D world built from 3Ds Max, it contains 2 boxes, In Director I have set the boxes to move along a path and when out of camera shot the boxes are reset along the Z axis and a new texture if applied (generated via a text member), so far so good.
Now if the user clicks a button I would like to clone the boxes and have each box display its own texture from its own text member. At the moment the cloned boxed all use the texture from the last textured box, I assume this is an inheritance issue, but I do not know how to make each texture unique the its box.
Any ideas?
Thanks in advance!
Sherv.Hello,
Im trying to make a number of boxes in a 3D world to move along the Z axis with a unique texture. The start just outside of the cameras field of view, move through the camera and when out of sight their position is moved back to the start with a new texture and the process repeats giving the illusion of endless boxes. The problem I am having is with the unique textures, I would like to reuse the shaders but without resetting the world. Currently I get the following message on line “ shad1 = w.newShader("shad1",#standard) “ :
cid:[email protected]
Below are snippets of the code for texturing the objects :
w = member(MyCameraSetup)
shad1 = w.newShader("shad1",#standard)
case ANPRcountry of
"UK" : tex1 = w.newTexture("tex1",#fromCastMember,member("ANPRtext"))
"Saudi" : tex1 = w.newTexture("tex1",#fromCastMember,member("ANPRSaudi"))
end case
shad1.texture = tex1
shad2 = w.newShader("shad2",#standard)
case ANPRcountry of
"UK" : tex2 = w.newTexture("tex2",#fromCastMember,member("ANPRtext2"))
"Saudi" : tex2 = w.newTexture("tex2",#fromCastMember,member("ANPRSaudi2"))
end case
shad2.texture = tex2
member(w).model(1).shader.texture = tex1
w.model(1).shader = w.shader("shad1")
member(w).texture("tex1").quality = #high
member(w).model(1).shader.transparent = False
w.shader("shad1").ambient = rgb(255,255,255)
w.shader("shad1").diffuse = rgb(255,255,255)
w.shader("shad1").emissive = rgb(0,0,0)
w.shader("shad1").specular = rgb(0,0,0)
-- setup the texture for far lane
member(w).model(5).shader.texture = tex2
w.model(2).shader = w.shader("shad2")
member(w).texture("tex2").quality = #high
member(w).model(5).shader.transparent = False
w.shader("shad2").ambient = rgb(255,255,255)
w.shader("shad2").diffuse = rgb(255,255,255)
w.shader("shad2").emissive = rgb(0,0,0)
w.shader("shad2").specular = rgb(0,0,0)
Any help you may provide will be gratefully received!
Many thanks.
Vector, the latest generation in ANPR camera technology is coming soon
Solutions to improve roads, journeys and communities
Sherwin Wallace
Research & Development Engineer
Vysionics ITS Ltd
Fishponds Close, Wokingham, Berkshire RG41 2QA
T: 0118 979 2077
F: 0118 977 4734
M: 07880554879
[email protected]<mailto:[email protected]>
http://www.vysionics.com<http://www.vysionics.com/>
cid:[email protected]
This email message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet emails are not necessarily secure. Vysionics ITS Ltd does not accept responsibility for changes made to this message after it was sent. -
Calling a Member Function from within a Cursor in a Procedure
Hello Folks
I'm a newbie to oracle and am in the process of learning 10G. My question is:
I created a type called row_po and defined a member function getCost() which returns the total cost of the order with line items as nested table, which i intend to call from within a procedure. In the procedure my SELECT returns multiple records and hence I need to use a cursor. For each record I've got to display the order_no, qty and order_cost (qty and order_cost are part of a line items nested table). I'm able to get to the order_no and qty but don't know how to call the member function to get the order_cost. Here's my procedure:
CREATE OR REPLACE PROCEDURE get_podet(part_num in number)
AS
CURSOR c2 is
SELECT *
FROM tab_po po, TABLE (po.LineItemList_nestab) L
WHERE L.PartNo = part_num;
BEGIN
FOR crec in c2 LOOP
DBMS_OUTPUT.PUT_LINE('ORDER NUMBER: ' || crec.PONo);
DBMS_OUTPUT.PUT_LINE('LINE QTY: ' || crec.Qty);
{color:#ff0000}*DBMS_OUTPUT.PUT_LINE('ORDER VALUE: ' || ''); -- order_cost which should be returned from the member function i've mentioned --*
{color}END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Failed' || 'SQLCODE: ' || SQLCODE);
DBMS_OUTPUT.PUT_LINE('SQL ERROR MESSAGE ' || SQLERRM);
END;
The line in red is where i want to call my function getCost() which is a member of tab_po po as mentioned in my SELECT.
Any thoughts highly appreciated.
Thanks and RegardsOne way would be to just run the query in a editor (sqlplus or toad) and see whats the column name.
Before that can you show us the structure of the type.
If you declare a table type without an object then the default column name is COLUMN_VALUE else the object filed name is taken.
Example without object in table type.
SQL> create or replace type tbl as table of integer
2 /
Type created.
SQL> create or replace function fn return tbl
2 as
3 ltbl tbl;
4 begin
5 select level bulk collect into ltbl
6 from dual
7 connect by level <= 10;
8
9 return ltbl;
10 end;
11 /
Function created.
SQL> select * from table(fn)
2 /
COLUMN_VALUE
1
2
3
4
5
6
7
8
9
10
10 rows selected.
Example with object in table type.
SQL> create or replace type obj as object(no integer)
2 /
Type created.
SQL> create or replace type tbl as table of obj
2 /
Type created.
SQL> edit
Wrote file afiedt.buf
1 create or replace function fn return tbl
2 as
3 ltbl tbl;
4 begin
5 select obj(level) bulk collect into ltbl
6 from dual
7 connect by level <= 10;
8 return ltbl;
9* end;
10 /
Function created.
SQL> select * from table(fn)
2 /
NO
1
2
3
4
5
6
7
8
9
10
10 rows selected.Edited by: Karthick_Arp on Jan 13, 2009 5:00 AM -
Cursor spending too much time cloning
I am profiling the performance of scanning through a database using a cursor. The breakdown looks something like this:
Total - 3800 ms
IN.fetchTarget - 1250 ms
IN.latch - 300 ms
Cursor.beginMoveCursor - 1260 ms
Cursor.endMoveCursor - 920 ms
Most of the time in begin and end move cursor is dealing with cloning. So effectively it is taking more time to deal with the cursor than to retrieve the data from disk. That doesn't sound right. Am I doing something wrong? Is there a way to not clone the cursor?
Instead of using the cursor if I use get for each element the time is comparable. Here is the breakdown
Total - 4800 ms
IN.fetchTarget - 1250 ms
Tree.search - 940 ms
Cursor.init - 1380 ms (almost all the time incrementing an atomic integer)
Cursor.close - 830 ms
Cursor.lockLN - 300 ms
I was hoping that by using the cursor I will cut down most of the overhead (search, repeated cursor init and close) and the time will come down to close to 1250 ms.I strongly suggest that rather than doing profiling, you look at your app throughput (without -ea or a profiler running), and look at the EnvironmentStats. The stats tell you what is going on in JE, and tuning based on the stats is normally the most fruitful. Looking at things in a profiler may help to optimize JE code itself, but is less likely to be fruitful for tuning your app, and a profiler is usually more beneficial after you have tuned the app, based on looking at the stats.
--mark -
How to preserve database user details before cloning
Hi Experts,
How to preserve database user details before cloning,
I am cloning the test database with the prod database, so my concern is how to preserve the users details which they have in TEST database( like roles, privilges, profiles , passwords, etc.....). Because that all gone after cloning from PROD.
Thanks
Samuse the following script to take the backup of roles,pwd & other details of DEV . after cloning execute the scripts back in DEV to restore the old values....
set head off
set lines 200
set pages 9999
col owner for a20
col db_link for a30
col username for a15
col host for a40
col created for a12
spool db_details.lst
select * from global_name;
select * from dba_db_links;
select name from v$controlfile;
select member from v$logfile;
select file_name from dba_data_files;
select file_name from dba_temp_files;
spool off
spool create_db_links.lst
select 'create DATABASE LINK '||owner#||'.'||NAME|| ' connect to '|| userid || ' identified by '|| password || ' using '||''''|| host ||''''||'; ' FROM sys.link$ order by owner#;
select username,user_id from dba_users where user_id in (select distinct owner# from link$);
spool off
spool alter_user.lst
select ' alter user '||username||' identified by values ' || chr(39)||password||chr(39) || ';' from dba_users;
spool off
Set verify off
Set space 0
set feedback off;
set echo off;
set pages 1000;
set lines 150;
spool create_synonym.sql
Select 'CREATE SYNONYM '||owner||'.'||synonym_name||' FOR '||table_owner||'.'||table_name||'@'||db_link||';' from dba_synonyms where db_link is not null and table_owner is not null;
Select 'CREATE SYNONYM '||owner||'.'||synonym_name||' FOR '||table_name||'@'||db_link||';' from dba_synonyms where db_link is not null and table_owner is null;
spool off;
Spool profile.sql
select ' alter user '||username||' profile '||PROFILE||';' from dba_users;
spool off -
Cloning a Database (and ORACLE_HOME
I want to make a total copy of a database and its ORACLE_HOME. To me, this looks like a two step process:
1) Clone the ORACLE_HOME. I completed this successfuly using GC (10.1.0.4)
2) Clone the database using that cloned ORACLE_HOME. This doesn't appear to work as the cloned ORACLE_HOME from #1 doesn't appear in the available ORACLE_HOME options. I did manually add entries in /etc/oratab and the oraInventory inventory.xml file (and bounced the agent) and still my ORACLE_HOME doesn't appear.
There also appears to be a way to add an ORACLE_HOME manually -- as it really isn't a database.Hello,
I’m not a trained DBA, and hardly have Patrick’s experience, and although he makes perfect sense, the following are three threads about cloning APEX, and none of them have a (reported) good ending:
Post Clone Apex steps
Blank screen after cloning database
After Cloning from Production Apex Doesnt Work
Maybe things are not that simple and straightforward, and the accumulated experience at Oracle Support suggests that what seems to be the long and hard way is actually the short and easy one. So, unless Patrick tells you that he has done/witness it himself (and as a member of the APEX development team, it’s highly possible), I would go with Oracle Support.
Just my 2¢.
Regards,
Arie.
♦ Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
♦ Author of Oracle Application Express 3.2 – The Essentials and More -
Brand new L440 with WD 1TB HDD.
Brand new Kingston HyperX 3K 240G SSD.
Goal: clone the HDD (at this point not much more than the OS - Windows 7 - there is 208G of free space) to the SSD. Software: Acronis True Image Home 2010 which I have had for a couple of years (used successfully to do the same thing 2 years ago with different equipment).
Disk manager sees both disks and pronounces them healthy.
Cloning setup: HDD in L440, SSD in USB3.0 docking station, connected to USB port on L440. Can see the SSD from the L440. Disk manager indicates that about 15G of storage is being used on the SSD.
Process begins, and a page or so of terse lines of code (white on black) come up and then process pauses (no indicator of anything happening).
Then nothing happens. For hours.
When I abort the process and check on the SSD, it's just as empty as it was at the beginning of the process.
Any ideas?
Thanks,Hi eyetrply,
using Acronis, or any other similar software, when cloning a ThinkPad I always reverse clone because not doing so can cause problems. Try cloning with the new SSD installed as primary drive with the original drive attached through USB 2.0 and not USB 3.0 which Acronis will not have the drivers for.
You can find a few articles on cloning in the forum's Knowledgebase, just search on "cloning acronis"
Andy ______________________________________
Please remember to come back and mark the post that you feel solved your question as the solution, it earns the member + points
Did you find a post helpfull? You can thank the member by clicking on the star to the left awarding them Kudos Please add your type, model number and OS to your signature, it helps to help you. Forum Search Option T430 2347-G7U W8 x64, Yoga 10 HD+, Tablet 1838-2BG, T61p 6460-67G W7 x64, T43p 2668-G2G XP, T23 2647-9LG XP, plus a few more. FYI Unsolicited Personal Messages will be ignored.
Deutsche Community Comunidad en Español English Community Русскоязычное Сообщество
PepperonI blog -
Renaming Existing Member Names
We are trying to do a long list of outline Member name changes (~200 changes) for Level 0 or Parent Level members and noticed the API function ESBOTLRENAMEMEMBER . It looks like this could be used by others and have seen several Threads in OTN talking about the function, but I haven't seen any posts pointing to a working Excel VBA to do a Find/Replace with this function. Can Anyone point to a working VBA code to do a find/ replace?
what I am trying to do is have a worksheet with a "Original Names" and a column with "New Names" and have the code to a loop through the list.
This sounds like a basic task that many folks could use. Does anyone have something similar that they have created?
Thanks ahead of time!
RobertI was doing exactly this recently with a 9.3.1 ASO cube. The forum will screw up the formatting but you can probably work out what's going on. Note the ???? placeholder for the number of lines and placeholders for APPNAME etc. This is very basic and features no error trapping - it was for a one time deal in a development environment, not regular and / or production use.
Any use is entirely at your own risk.
Good luck!
============================
Public Sub UpdateOutline()
Dim Init As ESB_INIT_T
Dim ObjDef As ESB_OBJDEF_T
Dim ProcState As ESB_PROCSTATE_T
Dim lngCount As Long
Dim strOldName As String
Dim strNewName As String
Dim lngInst As Long
Dim lngCtx As Long
Dim lngStatus As Long
Dim lngOutline As Long
Dim lngMember As Long
Dim intItems As Integer
'Init API
Init.Version = ESB_API_VERSION
lngStatus = EsbInit(Init, lngInst)
'Log in
lngStatus = EsbLogin(lngInst, "SERVER", "USERNAME", "PASSWORD", intItems, lngCtx)
'Open the outline
lngStatus = EsbSetActive(lngCtx, "APPNAME", "DBNAME", intItems)
With ObjDef
.AppName = "APPNAME"
.DbName = "DBNAME"
.FileName = "DBNAME"
.hCtx = lngCtx
.Type = ESB_OBJTYPE_OUTLINE
End With
lngStatus = EsbOtlOpenOutline(lngCtx, ObjDef, ESB_YES, ESB_YES, lngOutline)
'Loop through all members in the sheet
For lngCount = 1 To ????
strNewName = ActiveSheet.Cells(lngCount, 1)
strOldName = ActiveSheet.Cells(lngCount, 2)
lngStatus = EsbOtlFindMember(lngOutline, strOldName, lngMember)
lngStatus = EsbOtlRenameMember(lngOutline, lngMember, strNewName)
Next
'Write the outline
lngStatus = EsbOtlWriteOutline(lngOutline, ObjDef)
'Restructure
lngStatus = EsbOtlRestructure(lngCtx, ESB_DOR_ALLDATA)
'Call EsbGetProcessState until completed
lngStatus = EsbGetProcessState(lngCtx, ProcState)
While ProcState.State <> ESB_STATE_DONE
Application.Wait DateAdd("s", 10, Now())
lngStatus = EsbGetProcessState(lngCtx, ProcState)
Wend
'Unlock the outline
lngStatus = EsbUnlockObject(lngCtx, ESB_OBJTYPE_OUTLINE, "APPNAME", "DBNAME", "DBNAME")
'Close the outline
lngStatus = EsbOtlCloseOutline(lngOutline)
'Log out of server
lngStatus = EsbLogout(lngCtx)
'Terminate API instance
lngStatus = EsbTerm(lngInst)
End Sub -
Get AD Group Member Information
Hi BT
I started editing a PS script in PowerGUI and I wouldn't mind a second opinion before investing too much time on this.... I have a load of sp content rollup that needs to be done today but would like to come back to this ;-(
Get the AD groups in the OU
for each AD Group
Find each Member
For each Member well get their details as before e.g. LastLoginDate
pipe to CSV and hand to very grateful boss!
I think I am going to struggle in the nesting below.. and I don't have powergui on the AD machine.
$OU = 'OU=StormTroopersl,DC=DeathStar,DC=global'
Get-ADGroup -ldapfilter "(cn=*)" -SearchBase $OU -searchscope subtree -properties members | foreach {
$GroupName = $_.name
Get-ADGroupMember $_.DistinguishedName -recursive |
Select SamAccountName,@{n="GroupName";e={$GroupName}},@{n='TimeStamp';e={$TimeStamp}}}| foreach {
$SamAccountName = $_.samaccountname
Get-ADUser -Filter $SamAccountName -Properties emailaddress,description, company, LastLogonDate -SearchBase $OU | `
Select-Object name, emailaddress, description, company, LastLogonDate | Export-Csv -Path StormTroopersInGroupLastLogon.csv -NoTypeInformation
Regards
DanielForgive the following, as you may consider it off-topic and a bit of a rant. There is no LastLogonDate attribute in AD. Just as there is no FirstName, LastName, or EmailAddress attribute (and lots of other things exposed by PowerShell). I have
been searching for documentation on these "properties" and have found little yet. I believe these are what I would call property methods. They are methods that calculate values based on actual AD attributes. For example, the AccountExpirationDate property
method converts the accountExpires attribute (a large integer) into the equivalent date in the local time zone. In that case, a lot of code must be involved and it is very useful. Some cases are easy to understand. The FirstName "property" exposed by the DirectoryEntry
class is clearly the value of the givenName attribute. The LastName property method displays the value of the sn attribute. But I cannot find documentation on what LastLogonDate is. By testing I conclude that it is the value of the lastLogonTimeStamp
attribute converted into a date. In the interests of being "user friendly", Microsoft has obscured things so nobody knows whats going on. New admins will think users are identified by "Name", and they have FirstName and LastName attributes. If I
am correct that the LastLogonDate property method is the date equivalent of the lastLogonTimeStamp attribute (a large integer), then it will be accurate to within 14 days (in most cases). Assuming Windows 2003 functional level or above, the value of the lastLogonTimeStamp
is updated during logon only if the old value is more than 14 days in the past, then the new value is replicated to all other DC's. If instead LastLogonDate is based on the lastLogon attribute, then it is undoubtedly the value on only one DC. The
lastLogon attribute is always updated during logon, but only on the DC that authenticates the user, and the value is not replicated.
If someone has seen documentation on LastLogonDate as exposed by Get-ADUser, could you supply a link?
Richard Mueller - MVP Directory Services
ConvertDNWithBinaryToString CodeMethod
ConvertLargeIntegerToInt64 CodeMethod
accountExpires Property
badPasswordTime Property
badPwdCount Property
cn Property
codePage Property
countryCode Property
description Property
distinguishedName Property
dNSHostName Property
dSCorePropagationData Property
instanceType Property
isCriticalSystemObject Property
lastLogoff Property
lastLogon Property
The code is in error. There is no LastLogonDate.
This works:
Get-ADUser -Filter * -Properties mail,description, company, LastLogon
The whole question is hokey. It appears to be a fishing trip to get a solution.
Grant has the answer as best it can be offered for the lameness of the question.
jv
Maybe you are looking for
-
If a database server has a catastrophic failure and RMAN was run previously from that same database server are there any configuration files that RMAN would need to rebuild the database from backups stored on tape or is everything that RMAN needs sto
-
I want to know how to get the user and the password some time after doing the login. I knows the user from the user directory but i don't know how to get the password. Someone could give me an idea?
-
Wait Step - Delay in completion - Date/Time specified
Hi Experts, I've requirement to wait till a specific date/time to reach. For this, I've created a custom method to find out the date/time according to the factory calendar. I'm using a wait statement with option 'Wait for Condition' and condition men
-
Dear Experts, Our client requirement is : In FB03, They want to give multiple documents in Document list to get clearing documents against nature of expenses document. If it is single document then clearing document option availbe in the layout, whe
-
Lightroom 2.3 trial version loads pictures in grey in grid display and can"t see the picture
Tried looking for a setting to activate the modules library and develop shows grey boxes and shows the labels of the pictures loaded in raw but not the picture itself. In quick slideshow view, I can see an individual picture. I have attached scree