buildframework/helium/sf/java/metadata/src/com/nokia/helium/metadata/ant/taskdefs/MetaDataLogCountTask.java
--- a/buildframework/helium/sf/java/metadata/src/com/nokia/helium/metadata/ant/taskdefs/MetaDataLogCountTask.java Wed Jun 16 16:51:40 2010 +0300
+++ b/buildframework/helium/sf/java/metadata/src/com/nokia/helium/metadata/ant/taskdefs/MetaDataLogCountTask.java Fri Aug 13 14:59:05 2010 +0300
@@ -18,40 +18,66 @@
package com.nokia.helium.metadata.ant.taskdefs;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.ResourceCollection;
+
+import com.nokia.helium.metadata.MetadataException;
import com.nokia.helium.metadata.ant.conditions.MetaDataLogCondition;
+import com.nokia.helium.metadata.ant.types.SeverityEnum;
/**
* This class sets a property to the number of matching severity inside a Metadata db for a log.
* Example:
* <pre>
- * <hlm:metadataCountSeverity severity="error" log="*_fixslashes_raptor.log" db="${build.log.dir}/metadata.db" property="fixslashes.error"/>
+ * <hlm:metadataCountSeverity severity="error"
+ * log="${compile.log.dir}/${build.id}_fixslashes_raptor.log"
+ * database="${build.log.dir}/metadata_db"
+ * property="fixslashes.error" />
* </pre>
* @ant.task name="metadataCountSeverity" category="Metadata"
*/
public class MetaDataLogCountTask extends Task {
- private File fileName;
- private String logFile;
- private String severity;
+ private File database;
+ private File log;
+ private SeverityEnum severity;
private String property;
- private boolean countMissing = true;
+ private List<ResourceCollection> resourceCollections = new ArrayList<ResourceCollection>();
+
+ public void add(ResourceCollection resourceCollection) {
+ resourceCollections.add(resourceCollection);
+ }
/**
- * File to be parsed.
+ * Location of the database.
*
* @param filename
* @ant.required
*/
- public void setDb(File filename) {
- fileName = filename;
+ @Deprecated
+ public void setDb(File database) {
+ log("The usage of the db attribute is deprecated, please use the database attribute instead.", Project.MSG_WARN);
+ this.database = database;
+ }
+
+ /**
+ * Location of the database.
+ *
+ * @param filename
+ * @ant.required
+ */
+ public void setDatabase(File database) {
+ this.database = database;
}
- public void setLog(String log) {
- logFile = log;
+ public void setLog(File log) {
+ this.log = log;
}
/**
@@ -60,7 +86,7 @@
* @param severity
* @ant.required
*/
- public void setSeverity(String severity) {
+ public void setSeverity(SeverityEnum severity) {
this.severity = severity;
}
@@ -79,8 +105,9 @@
* for error severity
* @ant.not-required Default is true
*/
+ @Deprecated
public void setCountMissing(boolean countMissing) {
- this.countMissing = countMissing;
+ // not active anymore
}
/**
@@ -88,14 +115,21 @@
* @throws BuildException
*/
public void execute() {
- if (property == null)
+ if (property == null) {
throw new BuildException("'property' attribute is not defined");
-
- MetaDataLogCondition cond = new MetaDataLogCondition();
- cond.setDb(fileName);
- cond.setLog(logFile);
- cond.setSeverity(severity);
- cond.setCountMissing(countMissing);
- getProject().setNewProperty(property, "" + cond.getSeverity());
+ }
+ try {
+ MetaDataLogCondition cond = new MetaDataLogCondition();
+ cond.setProject(getProject());
+ cond.setDatabase(database);
+ cond.setLog(log);
+ cond.setSeverity(severity);
+ for (ResourceCollection rc : resourceCollections) {
+ cond.add(rc);
+ }
+ getProject().setNewProperty(property, "" + cond.getSeverity());
+ } catch (MetadataException ex) {
+ throw new BuildException(ex.getMessage(), ex);
+ }
}
}
\ No newline at end of file