Mercurial > hg > openmind
annotate src/main/java/org/mpi/openmind/scripts/ChangeAllEntitiesPrivacity.java @ 90:4b6c0b368f46
new UpdateMpiwgDigitalizations script.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 29 May 2018 21:15:06 +0200 |
parents | 979604ccc6db |
children |
rev | line source |
---|---|
1 | 1 package org.mpi.openmind.scripts; |
2 | |
3 import java.sql.Connection; | |
4 import java.sql.DriverManager; | |
5 import java.sql.SQLException; | |
6 import java.sql.Statement; | |
7 | |
8 import org.apache.commons.lang.StringUtils; | |
9 | |
83
979604ccc6db
rename ChangeEntityPrivacity.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
1
diff
changeset
|
10 public class ChangeAllEntitiesPrivacity { |
1 | 11 |
12 public static void execute(boolean privacity) { | |
13 try { | |
14 | |
15 Connection conn; | |
16 | |
17 Class.forName("com.mysql.jdbc.Driver").newInstance(); | |
18 String url = "jdbc:mysql://localhost/openmind?characterEncoding=UTF-8"; | |
19 conn = DriverManager.getConnection(url, "ismi", "ismipw"); | |
20 | |
21 | |
22 Statement st = conn.createStatement(); | |
23 //((privacity)? "1" : "0") | |
24 String sql = "UPDATE node SET public =" + privacity + ""; | |
25 System.out.println("Executing:"); | |
26 System.out.println(sql); | |
27 int n = st.executeUpdate(sql); | |
28 //System.out.println(n + " rows were modified"); | |
29 | |
30 conn.close(); | |
31 | |
32 } catch (ClassNotFoundException ex) { | |
33 System.err.println(ex.getMessage()); | |
34 ex.printStackTrace(); | |
35 } catch (IllegalAccessException ex) { | |
36 System.err.println(ex.getMessage()); | |
37 ex.printStackTrace(); | |
38 } catch (InstantiationException ex) { | |
39 System.err.println(ex.getMessage()); | |
40 ex.printStackTrace(); | |
41 } catch (SQLException ex) { | |
42 System.err.println(ex.getMessage()); | |
43 ex.printStackTrace(); | |
44 } | |
45 } | |
46 | |
47 public static void main(String[] args) { | |
48 String arg = args[0]; | |
49 System.out.println("arg: " + arg); | |
50 boolean privacity = false; | |
51 if(StringUtils.isNotEmpty(arg)){ | |
52 try{ | |
53 privacity = new Boolean(arg); | |
54 }catch (Exception e) { | |
55 e.printStackTrace(); | |
56 } | |
57 } | |
58 | |
83
979604ccc6db
rename ChangeEntityPrivacity.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
1
diff
changeset
|
59 ChangeAllEntitiesPrivacity.execute(privacity); |
1 | 60 System.exit(0); |
61 } | |
62 | |
63 } |