dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07374
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2097: Quickly fixed
------------------------------------------------------------
revno: 2097
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Mon 2010-09-13 12:22:43 +0200
message:
Quickly fixed
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataentryform/DataEntryFormServiceTest.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportParams.java
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFImportServiceTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2010-09-10 09:54:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2010-09-13 10:22:43 +0000
@@ -91,7 +91,18 @@
*/
String prepareDataEntryFormCode( String preparedCode );
- void convertDataEntryForm( DataEntryForm form, Map<Object, Integer> dataElementMap, Map<Object, Integer> categoryOptionComboMap );
+ /**
+ * Map the identifiers inside the HTML code according to the provided data
+ * element identifier and category option combo identifier mappings.
+ *
+ * @param htmlCode the HTML code.
+ * @param dataElementMap the mapping between data element identifiers to be
+ * converted.
+ * @param categoryOptionComboMap the mapping between category option combo
+ * identifiers to be converted.
+ * @return the converted HTML code.
+ */
+ String convertDataEntryForm( String htmlCode, Map<Object, Integer> dataElementMap, Map<Object, Integer> categoryOptionComboMap );
Collection<DataEntryForm> listDisctinctDataEntryFormByProgramStageIds( List<Integer> programStageIds );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2010-09-10 09:54:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2010-09-13 10:22:43 +0000
@@ -168,9 +168,9 @@
return sb.toString();
}
- public void convertDataEntryForm( DataEntryForm form, Map<Object, Integer> dataElementMap, Map<Object, Integer> categoryOptionComboMap )
+ public String convertDataEntryForm( String htmlCode, Map<Object, Integer> dataElementMap, Map<Object, Integer> categoryOptionComboMap )
{
- Matcher inputMatcher = INPUT_PATTERN.matcher( form.getHtmlCode() );
+ Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
StringBuffer buffer = new StringBuffer();
while ( inputMatcher.find() )
@@ -195,7 +195,7 @@
inputMatcher.appendTail( buffer );
- form.setHtmlCode( buffer.toString() );
+ return buffer.toString();
}
public Collection<DataEntryForm> listDisctinctDataEntryFormByProgramStageIds( List<Integer> programStageIds )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataentryform/DataEntryFormServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataentryform/DataEntryFormServiceTest.java 2010-09-10 09:54:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataentryform/DataEntryFormServiceTest.java 2010-09-13 10:22:43 +0000
@@ -106,11 +106,9 @@
categoryOptionComboMap.put( 3, 13 );
categoryOptionComboMap.put( 4, 14 );
- DataEntryForm form = new DataEntryForm( "FormA", htmlCodeA );
-
- dataEntryFormService.convertDataEntryForm( form, dataElementMap, categoryOptionComboMap );
-
- assertEquals( htmlCodeB, form.getHtmlCode() );
+ String code = dataEntryFormService.convertDataEntryForm( htmlCodeA, dataElementMap, categoryOptionComboMap );
+
+ assertEquals( htmlCodeB, code );
}
@Test(expected=RuntimeException.class)
@@ -119,9 +117,7 @@
Map<Object, Integer> dataElementMap = new HashMap<Object, Integer>();
Map<Object, Integer> categoryOptionComboMap = new HashMap<Object, Integer>();
- DataEntryForm form = new DataEntryForm( "FormA", htmlCodeA );
-
- dataEntryFormService.convertDataEntryForm( form, dataElementMap, categoryOptionComboMap );
+ dataEntryFormService.convertDataEntryForm( htmlCodeA, dataElementMap, categoryOptionComboMap );
fail();
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java 2010-07-16 20:12:45 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java 2010-09-13 10:22:43 +0000
@@ -66,7 +66,7 @@
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
+
@Autowired
private XMLPreConverter preConverter;
@@ -76,7 +76,7 @@
// -------------------------------------------------------------------------
// ImportService implementation
// -------------------------------------------------------------------------
-
+
@Override
public void importData( ImportParams params, InputStream inputStream )
throws ImportException
@@ -99,15 +99,13 @@
try
{
-
- if ( StreamUtils.isZip( bufin ) )
- {
- // if it's a zip file we must figure out what kind of package it is
+ if ( StreamUtils.isZip( bufin ) ) // If it's a ZIP file we must figure out what kind of package it is
+ {
log.info( "Zip file detected" );
+
tempZipFile = File.createTempFile( "IMPORT_", "_ZIP" );
- // save it to disk
- BufferedOutputStream ostream =
- new BufferedOutputStream( new FileOutputStream( tempZipFile ) );
+
+ BufferedOutputStream ostream = new BufferedOutputStream( new FileOutputStream( tempZipFile ) ); // Save it to disk
StreamUtils.streamcopy( bufin, ostream );
@@ -124,19 +122,20 @@
state.setMessage( "Unknown file type" );
throw new ImportException( "Unknown file type" );
}
- } else
+ }
+ else
{
if ( StreamUtils.isGZip( bufin ) )
{
- // pass through the uncompressed stream
- xmlDataStream = new BufferedInputStream( new GZIPInputStream( bufin ) );
- } else
+ xmlDataStream = new BufferedInputStream( new GZIPInputStream( bufin ) ); // Pass through the uncompressed stream
+ }
+ else
{
- // assume uncompressed xml and keep moving
- xmlDataStream = bufin;
+ xmlDataStream = bufin; // Assume uncompressed XML and keep moving
}
}
- } catch ( Exception ex )
+ }
+ catch ( Exception ex )
{
state.setMessage( "Error processing input stream" );
throw new ImportException( "Error processing input stream", ex );
@@ -151,13 +150,13 @@
try
{
if ( documentRootName.getLocalPart().equals( DXFConverter.DXFROOT ) )
- {
- // Native DXF stream - no transform required
- log.debug( "Importing dxf native stream" );
+ {
+ log.info( "Importing DXF native stream" ); // Native DXF stream, no transform required
dxfReader = XMLFactory.getXMLReader( xmlDataStream );
- } else
+ }
+ else
{
- log.debug( "Transforming stream" );
+ log.info( "Transforming stream" );
state.setMessage( "Transforming stream" );
transformOutput = File.createTempFile( "TRANSFORM_", ".xml" );
Source source = new StreamSource( xmlDataStream );
@@ -166,26 +165,25 @@
String xsltIdentifierTag = documentRootName.toString();
log.debug( "Tag for transformer: " + xsltIdentifierTag );
- //String currentUserName = currentUserService.getCurrentUsername();
preConverter.transform( source, result, xsltIdentifierTag, tempZipFile, null );
transformOutStream.flush();
transformOutStream.close();
- log.debug( "Transform successful" );
+ log.info( "Transform successful" );
dxfInStream = new FileInputStream( transformOutput );
dxfReader = XMLFactory.getXMLReader( dxfInStream );
}
- log.debug( "sending dxf to converter" );
+ log.debug( "Sending DXF to converter" );
converter.read( dxfReader, params, state );
-
- } catch ( Exception ex )
+ }
+ catch ( IOException ex )
{
throw new ImportException( "Failed to import stream", ex );
- } finally
+ }
+ finally
{
- // clean up whatever streams might be open
- if ( dxfReader != null )
+ if ( dxfReader != null ) // Clean up whatever streams might be open
{
dxfReader.closeReader();
}
@@ -208,12 +206,11 @@
{
zipFile.close();
}
- } catch ( IOException ex )
+ }
+ catch ( IOException ex )
{
- // this really shouldn't happen
log.warn( "Failed to close zipfile" );
}
}
}
}
-
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportParams.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportParams.java 2010-07-02 12:53:57 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportParams.java 2010-09-13 10:22:43 +0000
@@ -78,7 +78,7 @@
{
return false;
}
-
+
double _minorVersion = Double.parseDouble( minorVersion ) * 1000;
double _requiredVersion = Double.parseDouble( requiredVersion ) * 1000;
@@ -169,12 +169,6 @@
this.lastUpdated = lastUpdated;
}
- //----------------------------------------------------------------
- //
- // DXF parameters
- //
- //----------------------------------------------------------------
-
public String getNamespace()
{
return namespace;
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFImportServiceTest.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFImportServiceTest.java 2010-07-13 20:21:23 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFImportServiceTest.java 2010-09-13 10:22:43 +0000
@@ -92,7 +92,6 @@
public class DXFImportServiceTest
extends DhisTest
{
-
private final int dataASize = 3;
private final int dataBSize = 5;