Log Message
Updated the logging for the data dump.
Modified Paths
Diff
Modified: trunk/hudson/plugins/serenity/src/main/java/com/ikokoon/serenity/persistence/DataBaseToolkit.java (40899 => 40900)
--- trunk/hudson/plugins/serenity/src/main/java/com/ikokoon/serenity/persistence/DataBaseToolkit.java 2013-06-08 11:15:55 UTC (rev 40899)
+++ trunk/hudson/plugins/serenity/src/main/java/com/ikokoon/serenity/persistence/DataBaseToolkit.java 2013-06-08 12:00:57 UTC (rev 40900)
@@ -1,5 +1,7 @@
package com.ikokoon.serenity.persistence;
+import static com.ikokoon.serenity.persistence.IDataBase.DataBaseManager.getDataBase;
+
import java.util.List;
import org.apache.log4j.Logger;
@@ -19,7 +21,7 @@
/**
* Just some useful methods to dump the database and clean it.
- *
+ *
* @author Michael Couck
* @since 09.12.09
* @version 01.00
@@ -33,18 +35,17 @@
/**
* Clears the data in the database.
- *
- * @param dataBase
- * the database to truncate
+ *
+ * @param dataBase the database to truncate
*/
@SuppressWarnings("rawtypes")
- public static synchronized void clear(IDataBase dataBase) {
+ public static synchronized void clear(final IDataBase dataBase) {
Project<?, ?> project = (Project<?, ?>) dataBase.find(Project.class, Toolkit.hash(Project.class.getName()));
if (project != null) {
dataBase.remove(Project.class, project.getId());
}
List<Package> packages = dataBase.find(Package.class);
- for (Composite<?, ?> composite : packages) {
+ for (final Composite<?, ?> composite : packages) {
dataBase.remove(composite.getClass(), composite.getId());
}
List<Class> classes = dataBase.find(Class.class);
@@ -79,23 +80,22 @@
Collector.collectInnerClass(sourceInnerClass.getName(), sourceClass.getName());
Method sourceOuterMethod = sourceClass.getOuterMethod();
if (sourceOuterMethod != null) {
- Collector.collectOuterClass(sourceInnerClass.getName(), sourceClass.getName(), sourceOuterMethod.getName(), sourceOuterMethod
- .getDescription());
+ Collector.collectOuterClass(sourceInnerClass.getName(), sourceClass.getName(), sourceOuterMethod.getName(),
+ sourceOuterMethod.getDescription());
}
}
// Collector.collectSource(sourceClass.getName(), "source");
List<Method> sourceMethods = sourceClass.getChildren();
for (Method sourceMethod : sourceMethods) {
- Collector.collectComplexity(sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(), sourceMethod
- .getComplexity());
+ Collector.collectComplexity(sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(), sourceMethod.getComplexity());
Collector.collectAccess(sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(), sourceMethod.getAccess());
List<Line> sourceLines = sourceMethod.getChildren();
for (Line sourceLine : sourceLines) {
- Collector.collectLine(sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(), Integer
- .valueOf((int) sourceLine.getNumber()));
+ Collector.collectLine(sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(),
+ Integer.valueOf((int) sourceLine.getNumber()));
for (int i = 0; i < sourceLine.getCounter(); i++) {
- Collector.collectCoverage(sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(), (int) sourceLine
- .getNumber());
+ Collector.collectCoverage(sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(),
+ (int) sourceLine.getNumber());
}
}
}
@@ -139,11 +139,9 @@
/**
* Dumps the database to the output stream.
- *
- * @param dataBase
- * the database to dump
- * @param criteria
- * the criteria to match if the data for the composite must be written to the output
+ *
+ * @param dataBase the database to dump
+ * @param criteria the criteria to match if the data for the composite must be written to the output
*/
@SuppressWarnings("rawtypes")
public static synchronized void dump(IDataBase dataBase, ICriteria criteria, String message) {
@@ -162,27 +160,27 @@
}
try {
List<Package> packages = dataBase.find(Package.class);
- for (Package<?, ?> pakkage : packages) {
- log(criteria, pakkage, 1, pakkage.getId() + " : " + pakkage.getName() + ", coverage : " + pakkage.getCoverage() + ", complexity : "
- + pakkage.getComplexity() + ", stability : " + pakkage.getStability());
- for (Class<?, ?> klass : ((List<Class<?, ?>>) pakkage.getChildren())) {
- log(criteria, klass, 2, " : id : " + klass.getId() + " : name : " + klass.getName() + " : coverage : " + klass.getCoverage()
- + ", complexity : " + klass.getComplexity() + ", outer class : " + klass.getOuterClass() + ", outer method : "
- + klass.getOuterMethod() + ", lines : " + klass.getChildren().size() + ", inner classes : " + klass.getInnerClasses());
+ for (final Package<?, ?> pakkage : packages) {
+ log(criteria, pakkage, 1, pakkage.getId(), " : ", pakkage.getName(), ", coverage : ", pakkage.getCoverage(), ", complexity : ",
+ pakkage.getComplexity(), ", stability : ", pakkage.getStability());
+ for (final Class<?, ?> klass : ((List<Class<?, ?>>) pakkage.getChildren())) {
+ log(criteria, klass, 2, " : id : ", klass.getId(), " : name : ", klass.getName(), " : coverage : ", klass.getCoverage(), ", complexity : ",
+ klass.getComplexity(), ", outer class : ", klass.getOuterClass(), ", outer method : ", klass.getOuterMethod(), ", lines : ", klass
+ .getChildren().size(), ", inner classes : ", klass.getInnerClasses());
List<Efferent> efferents = klass.getEfferent();
List<Afferent> afferents = klass.getAfferent();
- for (Efferent efferent : efferents) {
+ for (final Efferent efferent : efferents) {
log(criteria, efferent, 4, efferent.getName());
}
- for (Afferent afferent : afferents) {
+ for (final Afferent afferent : afferents) {
log(criteria, afferent, 4, afferent.getName());
}
- for (Method<?, ?> method : ((List<Method<?, ?>>) klass.getChildren())) {
- log(criteria, method, 3, method.getId() + " : name : " + method.getName() + " : description : " + method.getDescription()
- + " : coverage : " + method.getCoverage() + ", complexity : " + method.getComplexity() + ", start time : "
- + method.getStartTime() + ", end time : " + method.getEndTime());
- for (Line<?, ?> line : ((List<Line<?, ?>>) method.getChildren())) {
- log(criteria, line, 4, line.getId() + " : number : " + line.getNumber() + ", counter : " + line.getCounter());
+ for (final Method<?, ?> method : ((List<Method<?, ?>>) klass.getChildren())) {
+ log(criteria, method, 3, method.getId().toString(), " : name : ", method.getName(), " : description : ", method.getDescription(),
+ " : coverage : ", method.getCoverage(), ", complexity : ", method.getComplexity(), ", start time : ", method.getStartTime()
+ + ", end time : ", method.getEndTime());
+ for (final Line<?, ?> line : ((List<Line<?, ?>>) method.getChildren())) {
+ log(criteria, line, 4, line.getId(), " : number : ", line.getNumber(), ", counter : ", line.getCounter());
}
}
}
@@ -192,7 +190,7 @@
}
}
- private static synchronized void log(ICriteria criteria, Composite<?, ?> composite, int tabs, String data) {
+ private static synchronized void log(ICriteria criteria, Composite<?, ?> composite, int tabs, Object... data) {
if (criteria == null || (criteria != null && criteria.satisfied(composite))) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < tabs; i++) {
@@ -200,7 +198,9 @@
}
builder.append(composite.getClass().getSimpleName());
builder.append(" : ");
- builder.append(data);
+ for (final Object datum : data) {
+ builder.append(datum);
+ }
logger.warn(builder.toString());
}
}
@@ -211,12 +211,17 @@
}
- public static void main(String[] args) {
- // D:/Eclipse/workspace/search/modules/Jar/serenity
- // D:/Eclipse/workspace/Discovery/modules/Jar/serenity
- IDataBase dataBase = IDataBase.DataBaseManager.getDataBase(DataBaseOdb.class,
- "D:/Eclipse/workspace/search/modules/Jar/serenity/serenity.odb", null);
- DataBaseToolkit.dump(dataBase, null, "Database dump : ");
+ public static void main(final String[] args) {
+ IDataBase dataBase = getDataBase(DataBaseOdb.class, "/usr/share/eclipse/workspace/ikube/code/core/serenity/serenity.odb", null);
+ DataBaseToolkit.dump(dataBase, new ICriteria() {
+ @SuppressWarnings("rawtypes")
+ public boolean satisfied(final Composite<?, ?> composite) {
+ if (Class.class.isAssignableFrom(composite.getClass())) {
+ return ((Class) composite).getName().contains("Test");
+ }
+ return false;
+ }
+ }, "Database dump : ");
dataBase.close();
}
You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
