Skip to content

Commit ba5bea5

Browse files
authored
Add files via upload
1 parent 435111d commit ba5bea5

File tree

7 files changed

+284
-28
lines changed

7 files changed

+284
-28
lines changed

AttributeMap.java

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
/*
2-
* To change this license header, choose License Headers in Project Properties.
3-
* To change this template file, choose Tools | Templates
4-
* and open the template in the editor.
2+
* The MIT License
3+
*
4+
* Copyright 2017 Arvind Sasikumar.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
523
*/
24+
625
package sync.db.mysql;
726

827
/**
9-
*
28+
* An object of this class maps an attribute of the source table to an attribute
29+
* of the destination table.
1030
* @author Arvind Sasikumar
1131
*/
1232
public class AttributeMap {
@@ -16,23 +36,63 @@ public class AttributeMap {
1636

1737
private final AttributeType type;
1838

19-
public AttributeMap(String sourceAttribute, String destinationAttribute, AttributeType type){
39+
/**
40+
* Create a new attribute map using this constructor.
41+
* The sourceAttribute and destinationAttribute parameters refer to the
42+
* source and destination attribute names respectively that are to be mapped
43+
* as found in their respective tables. The type parameter indicates whether
44+
* the datatype of the attributes to be mapped is of form
45+
* {@link sync.db.mysql.AttributeType#STRING} or
46+
* {@link sync.db.mysql.AttributeType#NUMERICAL}.
47+
* @param sourceAttribute attribute name in the source table
48+
* @param destinationAttribute corresponding attribute name in the
49+
* destination table
50+
* @param type specifies whether the attribute is of type
51+
* {@link sync.db.mysql.AttributeType#STRING} or
52+
* {@link sync.db.mysql.AttributeType#NUMERICAL},
53+
* as defined in the enum {@link sync.db.mysql.AttributeType}.
54+
* @see sync.db.mysql.AttributeType
55+
* @see sync.db.mysql.AttributeType#STRING
56+
* @see sync.db.mysql.AttributeType#NUMERICAL
57+
*/
58+
public AttributeMap(String sourceAttribute, String destinationAttribute,
59+
AttributeType type){
2060

2161
this.sourceAttribute = sourceAttribute;
2262
this.destinationAttribute = destinationAttribute;
2363
this.type = type;
2464
}
2565

66+
/**
67+
* Gets the attribute name of the source table in the current attribute
68+
* mapping.
69+
* @return attribute name of the source table in the current attribute
70+
* mapping
71+
*/
2672
public String getSourceAttribute(){
2773

2874
return sourceAttribute;
2975
}
3076

77+
/**
78+
* Gets the attribute name of the destination table in the current attribute
79+
* mapping.
80+
* @return attribute name of the destination table in the current attribute
81+
* mapping
82+
*/
3183
public String getDestinationAttribute(){
3284

3385
return destinationAttribute;
3486
}
3587

88+
/**
89+
* Gets the attribute type of the current attribute mapping.
90+
* @return type of the current attribute mapping, as defined by the enum
91+
* {@link sync.db.mysql.AttributeType}.
92+
* @see sync.db.mysql.AttributeType
93+
* @see sync.db.mysql.AttributeType#STRING
94+
* @see sync.db.mysql.AttributeType#NUMERICAL
95+
*/
3696
public AttributeType getType(){
3797

3898
return type;

AttributeType.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
/*
2-
* To change this license header, choose License Headers in Project Properties.
3-
* To change this template file, choose Tools | Templates
4-
* and open the template in the editor.
2+
* The MIT License
3+
*
4+
* Copyright 2017 Arvind Sasikumar.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
523
*/
24+
625
package sync.db.mysql;
726

827
/**

DBMap.java

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,73 @@
11
/*
2-
* To change this license header, choose License Headers in Project Properties.
3-
* To change this template file, choose Tools | Templates
4-
* and open the template in the editor.
2+
* The MIT License
3+
*
4+
* Copyright 2017 Arvind Sasikumar.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
523
*/
24+
625
package sync.db.mysql;
726

827
import java.util.ArrayList;
928

1029
/**
11-
*
30+
* An object of this class maps the source database to the destination database.
1231
* @author Arvind Sasikumar
1332
*/
1433
public class DBMap {
1534

1635
private final ArrayList<TableMap> tableMapList;
1736

37+
/**
38+
* Create a new database map using this constructor.
39+
* DBMap contains an {@link java.util.ArrayList} of
40+
* {@link sync.db.mysql.TableMap} objects, each of which maps one table
41+
* from the source database to another table in the destination database.
42+
* This ArrayList of TableMap is initialized in this constructor. TableMaps
43+
* are added to this ArrayList using
44+
* @link #addTableMap(sync.db.mysql.TableMap).
45+
*/
1846
public DBMap(){
1947

2048
tableMapList = new ArrayList<>();
2149
}
2250

51+
/**
52+
* Adds a mapping between one table of the source database to one
53+
* table of the destination database.
54+
* This mapping is specified in a {@link sync.db.mysql.TableMap} object for
55+
* each individual table mapping.
56+
* @param tableMap a TableMap object mapping a table of the source database
57+
* to a table of the destination database.
58+
*/
2359
public void addTableMap(TableMap tableMap){
2460

2561
tableMapList.add(tableMap);
2662
}
2763

64+
/**
65+
* Gets a set of all table mapping between the source and the destination
66+
* databases in an {@link java.util.ArrayList} form, of type
67+
* {@link sync.db.mysql.TableMap}.
68+
* @return set of all table mapping between the source and the destination
69+
* databases
70+
*/
2871
public ArrayList<TableMap> getTableMap(){
2972

3073
return tableMapList;

DBSyncAgent.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
/*
2-
* To change this license header, choose License Headers in Project Properties.
3-
* To change this template file, choose Tools | Templates
4-
* and open the template in the editor.
2+
* The MIT License
3+
*
4+
* Copyright 2017 Arvind Sasikumar.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
523
*/
24+
625
package sync.db.mysql;
726

827
import java.sql.*;

DBSynchronizer.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
/*
2-
* To change this license header, choose License Headers in Project Properties.
3-
* To change this template file, choose Tools | Templates
4-
* and open the template in the editor.
2+
* The MIT License
3+
*
4+
* Copyright 2017 Arvind Sasikumar.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
523
*/
24+
625
package sync.db.mysql;
726

827
import java.sql.*;

SyncType.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
/*
2-
* To change this license header, choose License Headers in Project Properties.
3-
* To change this template file, choose Tools | Templates
4-
* and open the template in the editor.
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright 2017 Arvind Sasikumar.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
523
*/
24+
625
package sync.db.mysql;
726

827
/**

0 commit comments

Comments
 (0)