Source Code Cross Referenced for SQLProjectGForge.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » databaseSQL » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » salome tmf » org.objectweb.salome_tmf.databaseSQL 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.salome_tmf.databaseSQL;
002:
003:        import java.sql.PreparedStatement;
004:        import java.sql.ResultSet;
005:        import java.util.Enumeration;
006:        import java.util.Hashtable;
007:        import java.util.Vector;
008:
009:        import org.objectweb.salome_tmf.api.ApiConstants;
010:        import org.objectweb.salome_tmf.api.data.GroupWrapper;
011:        import org.objectweb.salome_tmf.api.data.UrlAttachementWrapper;
012:        import org.objectweb.salome_tmf.api.data.UserWrapper;
013:        import org.objectweb.salome_tmf.api.sql.ISQLGroup;
014:        import org.objectweb.salome_tmf.api.sql.ISQLPersonne;
015:
016:        public class SQLProjectGForge extends SQLProject {
017:
018:            /**
019:             * Get a Vector of UserWrapper representing all the Users in the project projectName
020:             * And Upate Table Persone with GFORGE user of the project
021:             * @param projectName
022:             * @throws Exception
023:             */
024:            public UserWrapper[] getUsersOfProject(String projectName)
025:                    throws Exception {
026:                Vector resultSalome = new Vector();
027:
028:                Hashtable userSalome = new Hashtable();
029:                Hashtable userGforge = new Hashtable();
030:
031:                PreparedStatement prep = SQLEngine
032:                        .getSQLSelectQuery("selectAllProjectUsers"); //ok
033:                prep.setString(1, projectName);
034:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
035:
036:                while (stmtRes.next()) {
037:                    UserWrapper pUserWrapper = new UserWrapper();
038:                    pUserWrapper.setIdBDD(stmtRes.getInt("id_personne"));
039:                    pUserWrapper.setLogin(stmtRes.getString("login_personne"));
040:                    pUserWrapper.setName(stmtRes.getString("nom_personne"));
041:                    pUserWrapper
042:                            .setPrenom(stmtRes.getString("prenom_personne"));
043:                    pUserWrapper.setDescription(stmtRes
044:                            .getString("desc_personne"));
045:                    pUserWrapper.setEmail(stmtRes.getString("email_personne"));
046:                    pUserWrapper.setTel(stmtRes.getString("tel_personne"));
047:                    pUserWrapper.setCreateDate(stmtRes
048:                            .getDate("date_creation_personne"));
049:                    pUserWrapper.setCreateTime(stmtRes.getTime(
050:                            "heure_creation_personne").getTime());
051:                    pUserWrapper.setPassword(stmtRes.getString("mot_de_passe"));
052:                    resultSalome.add(pUserWrapper);
053:                    userSalome
054:                            .put(pUserWrapper.getLogin().trim(), pUserWrapper);
055:                }
056:
057:                /*prep = SQLEngineGForge.getSQLSelectGForgeQuery("selectAllGForgeUsers");
058:                stmtRes = SQLEngineGForge.runSelectQuery(prep);
059:                while  (stmtRes.next()) {
060:                	System.out.println(stmtRes);
061:                }*/
062:
063:                Vector resultGforge = new Vector();
064:                prep = SQLEngineGForge
065:                        .getSQLSelectGForgeQuery("selectAllGForgeProjectUsers");
066:                prep.setString(1, projectName);
067:                //prep.setString(1,"salome_demo");
068:
069:                stmtRes = SQLEngineGForge.runSelectQuery(prep);
070:                while (stmtRes.next()) {
071:                    //System.out.println("Add user GFORGE " + stmtRes);
072:                    UserWrapper pUserWrapper = new UserWrapper();
073:                    pUserWrapper.setIdBDD(stmtRes.getInt("user_id"));
074:                    pUserWrapper.setLogin(stmtRes.getString("user_name"));
075:                    pUserWrapper.setName(stmtRes.getString("lastname"));
076:                    pUserWrapper.setPrenom(stmtRes.getString("firstname"));
077:                    pUserWrapper.setDescription(stmtRes.getString("title"));
078:                    pUserWrapper.setEmail(stmtRes.getString("email"));
079:                    pUserWrapper.setTel(stmtRes.getString("phone"));
080:                    pUserWrapper.setPassword(stmtRes.getString("user_pw"));
081:                    resultGforge.add(pUserWrapper);
082:                    userGforge
083:                            .put(pUserWrapper.getLogin().trim(), pUserWrapper);
084:                }
085:
086:                //Ajout des Users GForge qui ne sont pas dans Salome 
087:                SQLEngineGForge.closeGforgeDB();
088:
089:                int transNumber = -1;
090:                int groupID;
091:                ISQLGroup pISQISQLGroup = SQLObjectFactory
092:                        .getInstanceOfISQLGroup();
093:                try {
094:                    transNumber = SQLEngine.beginTransaction(0,
095:                            ApiConstants.INSERT_GROUP);
096:
097:                    int projectID = getProject(projectName).getIdBDD();
098:                    GroupWrapper[] groupsOfTheProject = getProjectGroups(projectID);
099:                    GroupWrapper pGForgeGroupWrapper = null;
100:                    int i = 0;
101:                    boolean find = false;
102:                    while (!find && i < groupsOfTheProject.length) {
103:                        GroupWrapper pGroupWrapper = groupsOfTheProject[i];
104:                        if (pGroupWrapper.getName().trim().equals("GForge")) {
105:                            find = true;
106:                            pGForgeGroupWrapper = pGroupWrapper;
107:                        }
108:                        i++;
109:                    }
110:
111:                    if (pGForgeGroupWrapper == null) {
112:                        // Ajout du group GForge
113:                        groupID = pISQISQLGroup.insert(projectID, "GForge",
114:                                "Users registred in GForge", 254);
115:                    } else {
116:                        groupID = pGForgeGroupWrapper.getIdBDD();
117:                    }
118:                    SQLEngine.commitTrans(transNumber);
119:                } catch (Exception e) {
120:                    e.printStackTrace();
121:                    SQLEngine.rollBackTrans(transNumber);
122:
123:                    UserWrapper[] uwArray = new UserWrapper[resultSalome.size()];
124:                    for (int i = 0; i < resultSalome.size(); i++) {
125:                        uwArray[i] = (UserWrapper) resultSalome.get(i);
126:                    }
127:                    return uwArray;
128:                }
129:
130:                Enumeration loginGforgeEnum = userGforge.keys();
131:                ISQLPersonne pISQLPersonne = SQLObjectFactoryGforge
132:                        .getInstanceOfISQLPersonne();
133:                while (loginGforgeEnum.hasMoreElements()) {
134:                    try {
135:                        transNumber = SQLEngine.beginTransaction(0,
136:                                ApiConstants.INSERT_GROUP);
137:                        String login = (String) loginGforgeEnum.nextElement();
138:                        UserWrapper pSalomeUserWrapper = (UserWrapper) userSalome
139:                                .get(login);
140:                        UserWrapper pGForgeUserWrapper = (UserWrapper) userGforge
141:                                .get(login);
142:                        if (pSalomeUserWrapper == null) {
143:                            int userID = pISQLPersonne.insert(
144:                                    pGForgeUserWrapper.getLogin(),
145:                                    pGForgeUserWrapper.getName(),
146:                                    pGForgeUserWrapper.getPrenom(),
147:                                    pGForgeUserWrapper.getDescription(),
148:                                    pGForgeUserWrapper.getEmail(),
149:                                    pGForgeUserWrapper.getTel(),
150:                                    pGForgeUserWrapper.getPassword(), false);
151:
152:                            pISQISQLGroup.insertUser(groupID, userID);
153:
154:                            resultSalome.add(userGforge.get(login));
155:                        } else {
156:                            //update password
157:                            pISQLPersonne.updatePassword(login,
158:                                    pGForgeUserWrapper.getPassword(), false);
159:                        }
160:                        SQLEngine.commitTrans(transNumber);
161:                    } catch (Exception e) {
162:                        e.printStackTrace();
163:                        SQLEngine.rollBackTrans(transNumber);
164:                    }
165:                }
166:
167:                UserWrapper[] uwArray = new UserWrapper[resultSalome.size()];
168:                for (int i = 0; i < resultSalome.size(); i++) {
169:                    uwArray[i] = (UserWrapper) resultSalome.get(i);
170:                }
171:                return uwArray;
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.