Project

General

Profile

Revision 54d2eeaf

ID54d2eeaf29dab7d80b4c0236a9299c9df2b13266
Parent d014205f
Child ae5bebfa

Added by Andreas Müller over 1 year ago

ref #7357 fix TaxonName.clone test in model

View differences:

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

  
112 112
    }
113 113

  
114
    @Test
115
    public void testSomething(){
116
       String MCL = "MCL[0-9]{1,3}(\\-[0-9]{1,4}(\\-[0-9]{1,4}(\\-[0-9]{1,3}(\\-[0-9]{1,3})?)?)?)?";
117
//        String MCL = "a{1,3}";
118
        String filter = "Acc "+MCL;
119

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

  
114 154
}
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
		try{
124
		int i = 0;
125
	    try{
125 126
			profiler.startTx();
126 127
			TransactionStatus txStatus = getTransaction(partitionSize, partitionedIO);
127 128

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

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

  
134
            i = 2;
133 135
			profiler.startRelObjects();
134 136
			this.relatedObjects = partitionedIO.getRelatedObjectsForPartition(rs, state);
135
			state.setRelatedObjects(relatedObjects);
136

  
137
            i = 3;
138
            state.setRelatedObjects(relatedObjects);
139
            i = 4;
137 140
			profiler.startRs2();
138 141
			partitionResultSet = makePartitionResultSet();
139

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

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

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

  
152
            i = 8;
150 153
			logger.info("Saved " + getCurrentNumberOfRows() + " " + partitionedIO.getPluralString() );
151 154
			profiler.print();
152 155
		}catch(Exception e){
153
			String message = "Exception (%s) occurred while handling import partition for %s.";
154
			message = String.format(message, e.getLocalizedMessage(), partitionedIO.getPluralString());
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();
155 159
			throw new RuntimeException(message, e);
156 160
		}
157 161
	}
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;
29 30
import eu.etaxonomy.cdm.database.ICdmDataSource;
30 31
import eu.etaxonomy.cdm.database.update.DatabaseTypeNotSupportedException;
31 32

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

  
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

  
493 528

  
494 529
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonName.java
3496 3496
            result.typeDesignations = new HashSet<>();
3497 3497
            for (TypeDesignationBase<?> typeDesignation : getTypeDesignations()){
3498 3498
                TypeDesignationBase<?> newDesignation = (TypeDesignationBase<?>)typeDesignation.clone();
3499
                result.typeDesignations.add(newDesignation);
3500
                newDesignation.addTypifiedName(result);
3499
                this.removeTypeDesignation(newDesignation);
3500
                result.addTypeDesignation(newDesignation, false);
3501
//                result.typeDesignations.add(newDesignation);
3501 3502
            }
3502 3503

  
3503 3504
            //homotypicalGroup

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)