Project

General

Profile

Revision a4e5bf72

IDa4e5bf72191400df4b68b4ce2d39906c9505d791
Parent eae910af
Child daf3a3a2

Added by Andreas Müller over 2 years ago

remove unwanted commits

View differences:

cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/CdmUtilsTest.java
116 116

  
117 117
    }
118 118

  
119
    @Test
120
    public void testSomething(){
121
       String MCL = "MCL[0-9]{1,3}(\\-[0-9]{1,4}(\\-[0-9]{1,4}(\\-[0-9]{1,3}(\\-[0-9]{1,3})?)?)?)?";
122
//        String MCL = "a{1,3}";
123
        String filter = "Acc "+MCL;
124

  
125
       String notes = "Acc: 0x is Hieracium djimilense subsp. neotericum Zahn MCL293-3140-00-630";
126
       String result;
127
       if (notes.matches("Acc:.*")){
128
           if (notes.matches("Acc: .*\\$$") || (notes.matches("Acc: .*"+MCL))){
129
               result = null;
130
           }else if (notes.matches("Acc: .*(\\$|"+MCL+")\\s*\\{.*\\}")){
131
               notes = notes.substring(notes.indexOf("{")+1, notes.length()-1);
132
               result = notes;
133
           }else if (notes.matches("Acc: .*(\\$|"+MCL+")\\s*\\[.*\\]")){
134
               notes = notes.substring(notes.indexOf("[")+1, notes.length()-1);
135
               result = notes;
136
           }else{
137
               logger.warn("Namenote: " + notes);
138
               result = notes;
139
           }
140
       }else if (notes.matches("Syn:.*")){
141
           if (notes.matches("Syn: .*\\$$") || (notes.matches("Syn: .*"+MCL))){
142
               result = null;
143
           }else if (notes.matches("Syn: .*(\\$|"+MCL+")\\s*\\{.*\\}")){
144
               notes = notes.substring(notes.indexOf("{")+1, notes.length()-1);
145
               result = notes;
146
           }else if (notes.matches("Syn: .*(\\$|"+MCL+")\\s*\\[.*\\]")){
147
               notes = notes.substring(notes.indexOf("[")+1, notes.length()-1);
148
               result = notes;
149
           }else{
150
               logger.warn("Namenote: " + notes);
151
               result = notes;
152
           }
153
       }else{
154
           result = notes;
155
       }
156
       System.out.println(result);
157
    }
158

  
159 119
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/ResultSetPartitioner.java
121 121
	 * @param partitionedIO
122 122
	 */
123 123
	public void doPartition(IPartitionedIO<STATE> partitionedIO, STATE state) {
124
		int i = 0;
125
	    try{
124
		try{
126 125
			profiler.startTx();
127 126
			TransactionStatus txStatus = getTransaction(partitionSize, partitionedIO);
128 127

  
129
			i = 1;
130 128
			state.makeTransactionalSourceReference(partitionedIO.getReferenceService());
131 129

  
132 130
			profiler.startRs();
133 131
			ResultSet rs = makePartitionResultSet();
134
            i = 2;
132

  
135 133
			profiler.startRelObjects();
136 134
			this.relatedObjects = partitionedIO.getRelatedObjectsForPartition(rs, state);
137
            i = 3;
138
            state.setRelatedObjects(relatedObjects);
139
            i = 4;
135
			state.setRelatedObjects(relatedObjects);
136

  
140 137
			profiler.startRs2();
141 138
			partitionResultSet = makePartitionResultSet();
142
            i = 5;
139

  
143 140
			profiler.startDoPartition();
144 141
			partitionedIO.doPartition(this, state);
145
            i = 6;
142

  
146 143
			profiler.startDoCommit();
147 144
			partitionedIO.commitTransaction(txStatus);
148 145
			state.resetTransactionalSourceReference();
149
            i = 7;
146

  
150 147
			profiler.end();
151 148
			state.setRelatedObjects(null);
152
            i = 8;
149

  
153 150
			logger.info("Saved " + getCurrentNumberOfRows() + " " + partitionedIO.getPluralString() );
154 151
			profiler.print();
155 152
		}catch(Exception e){
156
			String message = "Exception (%s) occurred at position " + i + " while handling import partition for %s.";
157
			message = String.format(message, e.getMessage(), partitionedIO.getPluralString());
158
			e.printStackTrace();
153
			String message = "Exception (%s) occurred while handling import partition for %s.";
154
			message = String.format(message, e.getLocalizedMessage(), partitionedIO.getPluralString());
159 155
			throw new RuntimeException(message, e);
160 156
		}
161 157
	}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/Source.java
26 26
import org.apache.http.MethodNotSupportedException;
27 27
import org.apache.log4j.Logger;
28 28

  
29
import eu.etaxonomy.cdm.common.AccountStore;
30 29
import eu.etaxonomy.cdm.database.ICdmDataSource;
31 30
import eu.etaxonomy.cdm.database.update.DatabaseTypeNotSupportedException;
32 31

  
......
491 490
    	}
492 491
    }
493 492

  
494
    public static void main(String[] arg){
495
        Source source = EDAPHOBASE8();
496
        ResultSet a = source.getResultSet("SELECT count(*) FROM tax_taxon");
497
        try {
498
            a.next();
499
            long size = a.getLong(1);
500
        } catch (SQLException e) {
501
            // TODO Auto-generated catch block
502
            e.printStackTrace();
503
        }
504
        System.exit(0);
505
    }
506

  
507
    private static Source EDAPHOBASE8(){
508
        String dbms = Source.POSTGRESQL9;  //TODO 10
509
        String strServer = "130.133.70.26";  //BGBM-PESISQL
510
        String strDB = "cdm_edapho";
511
        int port = 5432; // 5433;
512
        String userName = "postgres";
513
        return  makeSource(dbms, strServer, strDB, port, userName, null);
514
    }
515

  
516
    private static Source makeSource(String dbms, String strServer, String strDB, int port, String userName, String pwd ){
517
        //establish connection
518
        Source source = null;
519
        source = new Source(dbms, strServer, strDB);
520
        source.setPort(port);
521

  
522
        pwd = AccountStore.readOrStorePassword(dbms, strServer, userName, pwd);
523
        source.setUserAndPwd(userName, pwd);
524
        // write pwd to account store
525
        return source;
526
    }
527

  
528 493

  
529 494
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)