WOLips Entity Modeler
WOLips Entity Modeler
- Subject: WOLips Entity Modeler
- From: Ron Lift <email@hidden>
- Date: Tue, 10 Feb 2009 11:21:34 -0500
I am converting our applications from WebObjects to use
Eclipse/WOLips/Project Wonder. We are still deploying to a OSX 10.4
server so we are running WO and Project wonder 5.3 frameworks. In all
our applications, we override the connection dictionary to the users
credentials. When I run the same code in WOLips, it will create 2
connections to the database server.
in the session we call a Login class to connect using the user
credentials. This creates a connection. Then in the session
application, we connect to the database to get some user information,
employe e number, email address, etc. This creates another connection.
In web objects this would not create a second connection
Login class
import com.webobjects.foundation.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;
public class Login extends EOCustomObject {
public static EOModel myModel;
public static NSArray myModelArray;
public static EOModelGroup myModelGroup;
public static EOAdaptor myAdaptor;
public static NSDictionary myDictionary ;
public static NSMutableDictionary newDictionary ;
public static Object keyObject;
public Login(){
}
public boolean userLogin(String userID, String password, EOEditingContext myEditingContext){
try {
myModelGroup = EOModelGroup.defaultGroup();
myModelArray = myModelGroup.models();
for ( int i = 0; i < myModelArray.count(); i++ ) {
myModel = (EOModel)myModelArray.
objectAtIndex(i);
String myModelString = myModel.name();
myAdaptor= (EOAdaptor)EOAdaptor.adaptorWithModel(myModel);
myDictionary = myAdaptor.connectionDictionary();
newDictionary = new NSMutableDictionary(myDictionary);
newDictionary.setObjectForKey(userID,"username");
newDictionary.setObjectForKey(password,"password");
System.out.println("\n\n" + newDictionary +"\n\n");
EOUtilities.connectWithModelNamed(myEditingContext, myModelString ,newDictionary );
}
return true;
}
catch(Exception e){
System.out.println("Cannot Connect" + e);
return false;
}
}
}
Session code fragments
EOEditingContext myEditingContext = defaultEditingContext();
loginSuccess = new Login().userLogin(userName, password, myEditingContext );
public Pdintses getPdintsesRecord(String ID){
NSMutableArray args = new NSMutableArray();
args.addObject( ID );
EOQualifier qualifier = EOQualifier.qualifierWithQualifierFormat( "user = %@", args );
EOFetchSpecification fetchSpec = new EOFetchSpecification( "Table", qualifier, null );
fetchSpec.setRefreshesRefetchedObjects( true );
NSArray allRecords = defaultEditingContext().objectsWithFetchSpecification(fetchSpec);
if ( allRecords.count() > 0 )
return ((Table)allRecords.objectAtIndex(0));
else
return null;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden