Skip to content

Commit 90ecd4e

Browse files
committed
Added the source
1 parent 12c6e0c commit 90ecd4e

File tree

9 files changed

+555
-0
lines changed

9 files changed

+555
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
5+
<classpathentry kind="lib" path="/opt/hypertable/0.9.6.5/lib/java/slf4j-log4j12-1.5.8.jar"/>
6+
<classpathentry kind="lib" path="/opt/hypertable/0.9.6.5/lib/java/slf4j-api-1.5.8.jar"/>
7+
<classpathentry kind="lib" path="/opt/hypertable/0.9.6.5/lib/java/log4j-1.2.13.jar"/>
8+
<classpathentry kind="lib" path="/home/kilua/UBB/Tesis/doc/TMC_etc/lib/mongo-2.9.0.jar"/>
9+
<classpathentry kind="output" path="bin"/>
10+
</classpath>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bin
2+
.metadata
3+
4+
#java specific
5+
*.class
6+
7+
## generic files to ignore
8+
*~
9+
*.lock
10+
*.DS_Store
11+
*.swp
12+
*.out
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>CurrentDesignToOneDocumentDesign</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.6
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.6
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package cl.alma.onedocument;
2+
3+
import java.util.Calendar;
4+
import java.util.GregorianCalendar;
5+
6+
/**
7+
* DocumentID class represent a MongoDB Object ID for the schema "One document
8+
* per component per day".
9+
*
10+
* @author Leonel Peña <[email protected]>
11+
*
12+
*/
13+
public class DocumentID {
14+
15+
//private Calendar _date;
16+
private String _antenna;
17+
private String _component;
18+
private String _monitorPoint;
19+
private String _id;
20+
private String _stringDate;
21+
22+
private int _year;
23+
private int _month;
24+
private int _day;
25+
26+
public static final String SEPARATOR = "/";
27+
28+
/**
29+
* Instantiate a new DocumentID object
30+
* @param date Date of the data.
31+
* @param antenna Antenna name, i.e., 'DV10', 'CM12'
32+
* @param component Component/subcomponent name, i.e., 'POL_MON4'
33+
*/
34+
//public DocumentID(Calendar date, String antenna, String component,
35+
public DocumentID(int year, int month, int day, String antenna, String component,
36+
String monitorPoint) {
37+
38+
this._year = year;
39+
this._month = month;
40+
this._day = day;
41+
this._antenna = antenna;
42+
this._component = component;
43+
this._monitorPoint = monitorPoint;
44+
45+
//_stringDate = Integer.toString(date.get(Calendar.YEAR)) +
46+
// Integer.toString(date.get(Calendar.MONTH)) +
47+
//Integer.toString(date.get(Calendar.DAY_OF_MONTH));
48+
//_date = new GregorianCalendar(year, month-1, day);
49+
_stringDate = Integer.toString(year) + "-" +
50+
Integer.toString(month) + "-" +
51+
Integer.toString(day);
52+
_id = _stringDate.replace("-", "") + SEPARATOR + antenna + SEPARATOR + component +
53+
SEPARATOR + monitorPoint;
54+
}
55+
56+
//public Calendar getDate() {
57+
//return _date;
58+
//}
59+
60+
public String getStringDate() {
61+
return _stringDate;
62+
}
63+
64+
public int getYear() {
65+
return _year;
66+
}
67+
68+
public int getMonth() {
69+
return _month;
70+
}
71+
72+
public int getDay() {
73+
return _day;
74+
}
75+
76+
public String getAntenna() {
77+
return _antenna;
78+
}
79+
80+
public String getComponent() {
81+
return _component;
82+
}
83+
84+
public String getMonitorPoint() {
85+
return _monitorPoint;
86+
}
87+
88+
@Override
89+
public String toString() {
90+
return _id;
91+
}
92+
93+
public static void main(String[] argv) {
94+
//Calendar date = new GregorianCalendar(2012, 7, 23, 13, 34, 59);
95+
DocumentID doc = new DocumentID(2012, 7, 23, "CM01", "LLC", "POL_MON1");
96+
System.out.println("DocumetID: "+doc+"\n Date: "+doc.getStringDate());
97+
}
98+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package cl.alma.onedocument;
2+
3+
import java.net.UnknownHostException;
4+
import java.util.concurrent.LinkedBlockingQueue;
5+
6+
import com.mongodb.DBObject;
7+
8+
public class Main {
9+
10+
/**
11+
* @param args
12+
*/
13+
public static void main(String[] args) {
14+
15+
LinkedBlockingQueue<DBObject> queue = new LinkedBlockingQueue<DBObject>();
16+
17+
MongoManager mongoManager = null;
18+
try {
19+
//mongoManager = new MongoManager("localhost",
20+
mongoManager = new MongoManager("mongo-r1.osf.alma.cl",
21+
"OneDocumentPerComponentPerDay", "monitorData");
22+
mongoManager.setQueue(queue);
23+
} catch (UnknownHostException e1) {
24+
e1.printStackTrace();
25+
}
26+
27+
Thread hiloMongo = new Thread(mongoManager);
28+
hiloMongo.start();
29+
30+
try {
31+
Query query = new Query("mongo-r1.osf.alma.cl", "MONDB",
32+
"monitorPoints");
33+
query.setQueue(queue);
34+
query.exportData();
35+
36+
// Once exportData() has been executed and the queue is empty
37+
// we interrupt the MongoManager thread
38+
while (!queue.isEmpty()) {
39+
try {
40+
Thread.sleep(3000);
41+
} catch (InterruptedException e) {
42+
e.printStackTrace();
43+
}
44+
}
45+
hiloMongo.interrupt();
46+
47+
} catch (UnknownHostException e) {
48+
e.printStackTrace();
49+
System.exit(-1);
50+
}
51+
}
52+
53+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package cl.alma.onedocument;
2+
3+
/**
4+
* Metadata class represent the metadata object for the schema "One document
5+
* per component per day".
6+
* @author Leonel Peña <[email protected]>
7+
*
8+
*/
9+
public class Metadata {
10+
11+
private DocumentID _documentID;
12+
private String _property;
13+
private String _location;
14+
private String _serialNumber;
15+
private int _sampleTime;
16+
private int _index;
17+
18+
public Metadata(DocumentID documentID, String property, String location,
19+
String serialNumber, int sampleTime, int index) {
20+
21+
this._documentID = documentID;
22+
this._property = property;
23+
this._location = location;
24+
this._serialNumber = serialNumber;
25+
this._sampleTime = sampleTime;
26+
this._index = index;
27+
}
28+
29+
public DocumentID getDocumentID() {
30+
return _documentID;
31+
}
32+
33+
public String getProperty() {
34+
return _property;
35+
}
36+
37+
public String getLocation() {
38+
return _location;
39+
}
40+
41+
public String getSerialNumber() {
42+
return _serialNumber;
43+
}
44+
45+
public int getSampleTime() {
46+
return _sampleTime;
47+
}
48+
49+
public int getIndex() {
50+
return _index;
51+
}
52+
53+
54+
}

0 commit comments

Comments
 (0)