├── LICENSE.md ├── QUICKSTART.md ├── README.md ├── google9e86a3a11f0c6b17.html ├── pom.xml └── src └── main ├── java └── com │ └── cisco │ └── app │ └── dbmigrator │ └── migratorapp │ ├── config │ ├── ApplicationContextProvider.java │ ├── MvcConfiguration.java │ └── SyncConfig.java │ ├── constants │ └── SyncConstants.java │ ├── controller │ ├── AdminController.java │ ├── DatabaseDetailsController.java │ ├── ESController.java │ ├── HomeController.java │ ├── SyncEventController.java │ └── SyncMapController.java │ ├── core │ ├── Main.java │ ├── event │ │ ├── EventType.java │ │ ├── MongoToOracleEvent.java │ │ ├── MongoToOracleSyncEvent.java │ │ ├── O2MSyncDataLoader.java │ │ ├── OracleParallelReadInfo.java │ │ ├── OracleToMongoEvent.java │ │ ├── OracleToMongoGridFsEvent.java │ │ ├── OracleToMongoSyncEvent.java │ │ ├── SyncError.java │ │ ├── SyncEvent.java │ │ ├── SyncMarker.java │ │ └── range │ │ │ ├── DataRange.java │ │ │ ├── DateRangeDivisor.java │ │ │ ├── IntRangeDivisor.java │ │ │ ├── RangeDivisor.java │ │ │ └── RangeDivisorFactory.java │ ├── job │ │ ├── EventJob.java │ │ ├── NodeBalancer.java │ │ ├── NodeMonitorJob.java │ │ ├── O2MEventDistributor.java │ │ ├── O2MEventDistributorNew.java │ │ └── SyncStatus.java │ ├── map │ │ ├── ColumnAttrMapper.java │ │ ├── MapType.java │ │ ├── MongoToOracleMap.java │ │ ├── OracleToMongoGridFsMap.java │ │ ├── OracleToMongoMap.java │ │ └── SyncMap.java │ ├── meta │ │ ├── es │ │ │ ├── EsAttribute.java │ │ │ ├── EsEntity.java │ │ │ ├── EsEntityTypes.java │ │ │ ├── EsMngAttrMapper.java │ │ │ ├── EsObject.java │ │ │ ├── MappedCollectionInfo.java │ │ │ └── package-info.java │ │ ├── mongo │ │ │ ├── MongoAttribute.java │ │ │ ├── MongoAttributeType.java │ │ │ ├── MongoEntity.java │ │ │ ├── MongoGridData.java │ │ │ ├── MongoLiteralFactory.java │ │ │ └── MongoObject.java │ │ └── oracle │ │ │ └── NodeGroup.java │ └── thread │ │ ├── MngOpLogReader.java │ │ ├── MngToOrclReader.java │ │ ├── MngToOrclSync.java │ │ ├── MngToOrclSyncWriter.java │ │ ├── MngToOrclWriter.java │ │ ├── OrclToMngGridFsReader.java │ │ ├── OrclToMngGridFsWriter.java │ │ ├── OrclToMngReader.java │ │ ├── OrclToMngSyncReader.java │ │ ├── OrclToMngSyncWriter.java │ │ ├── OrclToMngWriter.java │ │ └── SyncOperation.java │ ├── interceptor │ └── HttpAuthInterceptor.java │ ├── logging │ ├── codecs │ │ ├── MngToOrclEventCodec.java │ │ ├── MngToOrclMapCodec.java │ │ ├── MngToOrclSyncEventCodec.java │ │ ├── O2MSyncEventLogCodec.java │ │ ├── OrclToMngEventCodec.java │ │ ├── OrclToMngGridFsEventCodec.java │ │ ├── OrclToMngMapCodec.java │ │ ├── OrclToMngSyncEventCodec.java │ │ ├── OrclToMongoGridFsMapCodec.java │ │ ├── SyncAttrs.java │ │ ├── SyncConnectionInfoCodec.java │ │ ├── SyncErrorCodec.java │ │ ├── SyncEventCodec.java │ │ ├── SyncEventGridFsCodec.java │ │ ├── SyncMapAndEventDecoder.java │ │ ├── SyncMapAndEventEncoder.java │ │ ├── SyncMapAndEventGridFsDecoder.java │ │ ├── SyncMapAndEventGridFsEncoder.java │ │ ├── SyncMapCodec.java │ │ ├── SyncMapGridFsCodec.java │ │ ├── SyncMarkerCodec.java │ │ ├── SyncNodeCodec.java │ │ ├── SyncNodeDecoder.java │ │ ├── SyncNodeDetailsCodec.java │ │ ├── SyncNodeEncoder.java │ │ ├── SyncUserDetailCodec.java │ │ └── SyncUserSessionCodec.java │ ├── connection │ │ ├── ApplicationCollections.java │ │ └── MongoConnection.java │ ├── dao │ │ ├── O2MEventLogDao.java │ │ ├── SyncConnectionDao.java │ │ ├── SyncEventDao.java │ │ ├── SyncMapDao.java │ │ ├── SyncNodeDao.java │ │ ├── SyncNodeDetailsDao.java │ │ ├── SyncUserDao.java │ │ └── SyncUserSessionDao.java │ ├── entities │ │ ├── O2MSyncEventLog.java │ │ ├── SyncConnectionInfo.java │ │ ├── SyncNode.java │ │ ├── SyncUser.java │ │ ├── SyncUserSession.java │ │ └── UserActivity.java │ └── entity │ │ └── SyncNodeDetails.java │ ├── mail │ └── Mailer.java │ ├── service │ ├── AdminService.java │ ├── AdminServiceImpl.java │ ├── CollectionsDetailsService.java │ ├── CollectionsDetailsServiceImpl.java │ ├── DatabaseDetailsService.java │ ├── DatabaseDetailsServiceImpl.java │ ├── SyncEventService.java │ ├── SyncEventServiceImpl.java │ ├── SyncMapService.java │ ├── SyncMapServiceImpl.java │ ├── SyncNodeDetailsService.java │ └── SyncNodeDetailsServiceImpl.java │ ├── sqlbuilder │ ├── entities │ │ ├── BigDecimalLiteral.java │ │ ├── BlobLiteral.java │ │ ├── ClobLiteral.java │ │ ├── DateLiteral.java │ │ ├── JoinType.java │ │ ├── JoinedTable.java │ │ ├── Literal.java │ │ ├── LogicalOperator.java │ │ ├── MatchAble.java │ │ ├── MatchOperator.java │ │ ├── MatchWithColumn.java │ │ ├── NullLiteral.java │ │ ├── NumberLiteral.java │ │ ├── OracleColumn.java │ │ ├── OracleEntity.java │ │ ├── OracleTable.java │ │ ├── OracleTimeStampLiteral.java │ │ ├── QueryConstants.java │ │ ├── RowIdLiteral.java │ │ ├── Selectable.java │ │ ├── SortByColumn.java │ │ ├── SortOrder.java │ │ ├── SqlColumnType.java │ │ ├── SqlLiteralFactory.java │ │ ├── TimeStampLiteral.java │ │ └── VarcharLiteral.java │ ├── queries │ │ ├── DeleteQueryBuilder.java │ │ ├── InsertQueryBuilder.java │ │ ├── InsertQueryComponents.java │ │ ├── MergeQueryBuilder.java │ │ ├── MergeQueryComponents.java │ │ ├── QueryBuilder.java │ │ ├── SelectQueryBuilder.java │ │ ├── SelectQueryComponents.java │ │ ├── UpdateQueryBuilder.java │ │ └── UpdateQueryComponents.java │ └── sqlcomponents │ │ ├── LogicalOperation.java │ │ ├── MatchOperation.java │ │ ├── Operations.java │ │ ├── OperationsFactory.java │ │ ├── SQLFilters.java │ │ └── SetOperation.java │ └── utilities │ ├── cache │ └── DBCacheManager.java │ ├── encrypt │ └── EncryptorDecryptor.java │ ├── mongo │ └── MongoDbUtilities.java │ └── oracle │ ├── DbResourceUtils.java │ └── OracleDBUtilities.java └── webapp ├── WEB-INF ├── views │ ├── home.jsp │ ├── i │ │ └── buttonBG-H.jpg │ └── jsp │ │ ├── footer.jsp │ │ └── header.jsp └── web.xml └── resources ├── applicationContext.xml ├── css ├── font-awesome.css ├── font-awesome.min.css ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── lib │ ├── angular-material.min.css │ ├── bootstrap-theme.min.css │ ├── bootstrap.min.css │ └── jquery-ui.min.css └── migrator.css ├── fonts ├── FontAwesome.otf ├── fontawesome-webfont.eot ├── fontawesome-webfont.svg ├── fontawesome-webfont.ttf ├── fontawesome-webfont.woff └── fontawesome-webfont.woff2 ├── js ├── DBAssignManagerView.js ├── DBMigratorApp.js ├── adminViewControllers.js ├── controllers.js ├── directives.js ├── homeViewControllers.js ├── jquery-2.1.4.min.js ├── lib │ ├── angular-animate.min.js │ ├── angular-aria.min.js │ ├── angular-cookies.min.js │ ├── angular-material.min.js │ ├── angular-messages.min.js │ ├── angular-resource.min.js │ ├── angular-route.min.js │ ├── angular.js │ ├── angular.min.js │ ├── bootstrap.min.js │ ├── jquery-2.1.4.min.js │ ├── jquery-ui.min.js │ ├── smart-table.js │ ├── smart-table.min.js │ ├── tabs.js │ └── ui-bootstrap-tpls-1.2.4.js ├── logo.png ├── migrateReverseViewControllers.js ├── migrateViewControllers.js ├── migrateViewSourceControllers.js ├── migrateViewTargetControllers.js ├── selectDBViewControllers.js ├── services.js └── tableRelationsEditorController.js ├── log4j.properties ├── logo └── logo.png ├── mailTemplate ├── cancelledEventMailTemplate.html ├── completedEventMailTemplate.html ├── failedNodeMailTemplate.html ├── failureEventMailTemplate.html └── startedEventMailTemplate.html ├── sync ├── certs │ ├── keystore │ └── trustStore ├── db-props │ ├── dev.properties │ ├── local.properties │ ├── lt.properties │ ├── prod.properties │ └── stage.properties ├── mailer.properties └── sync.conf └── templates ├── DBAssignManagerTemplates.html ├── adminPageTemplates.html ├── homeViewTemplates.html ├── migrateViewReverseTemplates.html ├── migrateViewTemplates.html ├── plugInTemplates.html ├── popupFactoryTemplates.html ├── selectDBViewTemplates.html └── tableRelationsEditorTemplate.html /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Cisco Systems Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### SYNC 2 | 3 | *** 4 | 5 | 6 | This product is built for bi-directional data migration between MongoDB & RDBMS databases. 7 | ## **Features:** 8 | * Should work with virtually any SQL database (using JDBC). Tested with Oracle and MySQL. 9 | * Simple & intuitive UI for creating mapping between databases & tracking real time migration. 10 | * Generic tool to create any kind of joins in RDBMS. 11 | * Create mapping once & use export/import feature to migrate mapping to other environments. 12 | * View/Edit/Delete mapping features for the existing mappings. Stop/Restart/Cancel features for the events. 13 | * Email notifications for start & end of the migration with complete summary. 14 | * Failure notifications with the complete details of failure reason & data record. 15 | * Auto restart of events in case of JVM bounce. 16 | * Admin module to add new databases & provide access. 17 | * Batch select/insert, to significantly improve performance. 18 | * Using OpLog for reading data from MongoDB instead of querying the database. 19 | 20 | 21 | Demo: https://www.slideshare.net/mongodb/transforming-a-large-missioncritical-ecommerce-platform-from-a-relational-architecture-to-mongodb 22 | -------------------------------------------------------------------------------- /google9e86a3a11f0c6b17.html: -------------------------------------------------------------------------------- 1 | google-site-verification: google9e86a3a11f0c6b17.html -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/config/ApplicationContextProvider.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.config; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | 7 | public class ApplicationContextProvider implements ApplicationContextAware{ 8 | 9 | private static ApplicationContext context; 10 | 11 | public static ApplicationContext getApplicationContext() { 12 | return context; 13 | } 14 | 15 | @Override 16 | public void setApplicationContext(ApplicationContext ac) 17 | throws BeansException { 18 | context = ac; 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/constants/SyncConstants.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.constants; 2 | 3 | /** 4 | * ENUM to hold Application level constants 5 | * 6 | * @author pnilayam 7 | * 8 | */ 9 | public enum SyncConstants { 10 | CONST; 11 | public static final String USER= "user"; 12 | public static final String CONTENT_TYPE_JSON = "application/json"; 13 | public static final String EMPTY_STRING = ""; 14 | public static final String SUCCESS = "Success"; 15 | public static final int DEFAULT_BATCH_SIZE =10; 16 | public static final String SYNC_FLAG = "syncFlg"; 17 | public static final String Y = "Y"; 18 | public static final String SRC= "src"; 19 | public static final String ORCL= "orcl"; 20 | public static final String SYNC_TIME = "syncedOn"; 21 | public static final String OPERATION = "o"; 22 | public static final String DELETE = "DELETE"; 23 | 24 | /** 25 | * Constants to load configurations 26 | */ 27 | public static final String LIFE = "LIFE"; 28 | public static final String APP_ID = "APP_ID"; 29 | public static final String IS_PWD_ENCRYPTED = "IS_PWD_ENCRYPTED"; 30 | public static final String ENCRYPTION_KEY = "ENCRYPTION_KEY"; 31 | public static final String SSL_ENABLED = "SSL_ENABLED"; 32 | public static final String SSL_ALLOW_INVALID_HOST = "SSL_ALLOW_INVALID_HOST"; 33 | public static final String KEYSTORE_NAME = "KEYSTORE_NAME"; 34 | public static final String KEYSTORE_PASS = "KEYSTORE_PASS"; 35 | public static final String KEYSTORE_PATH = "KEYSTORE_PATH"; 36 | public static final String TRUSTSTORE_NAME = "TRUSTSTORE_NAME"; 37 | public static final String TRUSTSTORE_PASS = "TRUSTSTORE_PASS"; 38 | public static final String TRUSTSTORE_PATH = "TRUSTSTORE_PATH"; 39 | public static final String WRITE_CONCERN = "WRITE_CONCERN"; 40 | public static final String LOGGING_LEVEL = "LOGGING_LEVEL"; 41 | 42 | /** 43 | * DB Property Constants 44 | */ 45 | public static final String DBNAME = "DBNAME"; 46 | public static final String USERNAME = "USERNAME"; 47 | public static final String PORT = "PORT"; 48 | public static final String HOST = "HOST"; 49 | public static final String PASSWORD = "PASSWORD"; 50 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/controller/ESController.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.controller; 2 | 3 | import java.util.List; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | import org.apache.log4j.Logger; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | 12 | import com.cisco.app.dbmigrator.migratorapp.constants.SyncConstants; 13 | import com.cisco.app.dbmigrator.migratorapp.core.meta.mongo.MongoObject; 14 | import com.cisco.app.dbmigrator.migratorapp.service.CollectionsDetailsService; 15 | import com.cisco.app.dbmigrator.migratorapp.service.CollectionsDetailsServiceImpl; 16 | import com.google.gson.Gson; 17 | 18 | 19 | @Controller 20 | public class ESController { 21 | private static final Logger logger = Logger.getLogger(ESController.class); 22 | 23 | @RequestMapping(value="/getAllCollections") 24 | public void getAllCollections(HttpServletRequest request,HttpServletResponse response){ 25 | Gson gson = new Gson(); 26 | String collectionListJson = ""; 27 | String sourceDatabaseName = request.getParameter("sourceDatabaseName")!=null ? request.getParameter("sourceDatabaseName").trim() : null; 28 | String sourceSchemaName = request.getParameter("sourceSchemaName")!=null ? request.getParameter("sourceSchemaName").trim() : null; 29 | CollectionsDetailsService collectionDetailsService = new CollectionsDetailsServiceImpl(); 30 | try { 31 | List collectionList = collectionDetailsService.getAllCollections(sourceDatabaseName, sourceSchemaName); 32 | collectionListJson = gson.toJson(collectionList); 33 | response.setContentType(SyncConstants.CONTENT_TYPE_JSON); 34 | response.getWriter().println(collectionListJson); 35 | } catch (Exception e) { 36 | logger.info("Exception while fetching collection "+e.getMessage()); 37 | } 38 | } 39 | 40 | @RequestMapping(value="/getAttributesForCollection") 41 | public void getAttributesForCollection(HttpServletRequest request,HttpServletResponse response){ 42 | Gson gson = new Gson(); 43 | String attrListJson = ""; 44 | String sourceDatabaseName = request.getParameter("sourceDatabaseName")!=null ? request.getParameter("sourceDatabaseName").trim() : null; 45 | String sourceSchemaName = request.getParameter("sourceSchemaName")!=null ? request.getParameter("sourceSchemaName").trim() : null; 46 | String collectionName = request.getParameter("collectionName")!=null ? request.getParameter("collectionName") : null; 47 | CollectionsDetailsService collectionDetailsService = new CollectionsDetailsServiceImpl(); 48 | try { 49 | MongoObject obj = collectionDetailsService.processCollection(sourceDatabaseName,sourceSchemaName,collectionName); 50 | attrListJson = gson.toJson(obj); 51 | response.setContentType(SyncConstants.CONTENT_TYPE_JSON); 52 | response.getWriter().println(attrListJson); 53 | System.out.println(attrListJson); 54 | } catch (Exception e) { 55 | logger.info("Exception while fetching attributes for collection "+e.getMessage()); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/controller/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.controller; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.http.HttpServletResponse; 6 | 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.ResponseBody; 11 | import org.springframework.web.servlet.ModelAndView; 12 | 13 | import com.cisco.app.dbmigrator.migratorapp.constants.SyncConstants; 14 | 15 | @Controller 16 | public class HomeController { 17 | 18 | @RequestMapping(value="/") 19 | public ModelAndView test(HttpServletResponse response) throws IOException{ 20 | return new ModelAndView("home"); 21 | 22 | } 23 | @RequestMapping(value = "/pingpong.html", method = RequestMethod.HEAD) 24 | @ResponseBody 25 | public String getServerStatus() { 26 | return SyncConstants.SUCCESS; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/event/EventType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.cisco.app.dbmigrator.migratorapp.core.event; 5 | 6 | /** 7 | * Enum to Hold supported typed of Events 8 | * 9 | * @author pnilayam 10 | * 11 | */ 12 | public enum EventType { 13 | OrclToMongo,MongoToOrcl,MongoToOrclSync,OrclToMongoSync,System,OrclToMongoGridFs; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/event/MongoToOracleEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.cisco.app.dbmigrator.migratorapp.core.event; 5 | 6 | import java.util.concurrent.LinkedBlockingQueue; 7 | 8 | import org.bson.BsonDocument; 9 | import org.bson.BsonDocumentWrapper; 10 | import org.bson.Document; 11 | import org.bson.codecs.configuration.CodecRegistry; 12 | 13 | import com.cisco.app.dbmigrator.migratorapp.core.map.MongoToOracleMap; 14 | import com.cisco.app.dbmigrator.migratorapp.core.thread.MngToOrclReader; 15 | import com.cisco.app.dbmigrator.migratorapp.core.thread.MngToOrclWriter; 16 | import com.cisco.app.dbmigrator.migratorapp.logging.dao.SyncMapDao; 17 | 18 | /** 19 | * Runnable class to process MongoDB to OracleDB migration (one time data transfer) events. 20 | * 21 | * @author pnilayam 22 | * 23 | */ 24 | public class MongoToOracleEvent extends SyncEvent{ 25 | private String collectionName; 26 | @Override 27 | public void run() { 28 | mappingDao = new SyncMapDao(); 29 | dataBuffer= new LinkedBlockingQueue(batchSize); 30 | MongoToOracleMap map = (MongoToOracleMap) mappingDao.getMapping(mapId); 31 | MngToOrclReader reader = new MngToOrclReader(dataBuffer, map.getSourceDbName(), map.getSourceUserName(), map.getCollectionName(), batchSize); 32 | Thread readerThread = new Thread(reader); 33 | readerThread.setName(eventName+"_Reader"); 34 | readerThread.start(); 35 | MngToOrclWriter writer = new MngToOrclWriter(dataBuffer, map); 36 | Thread writerThread = new Thread(writer); 37 | writerThread.setName(eventName+"_Writer"); 38 | writerThread.start(); 39 | } 40 | 41 | @Override 42 | public BsonDocument toBsonDocument(Class arg0, CodecRegistry codecRegistry) { 43 | return new BsonDocumentWrapper(this, codecRegistry.get(MongoToOracleEvent.class)); 44 | } 45 | 46 | public String getCollectionName() { 47 | return collectionName; 48 | } 49 | 50 | public void setCollectionName(String collectionName) { 51 | this.collectionName = collectionName; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/event/OracleParallelReadInfo.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.event; 2 | 3 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleColumn; 4 | 5 | /** 6 | * Bean to hold Parallel Read info while reading data from OracleDB. 7 | * 8 | * @author pnilayam 9 | * 10 | */ 11 | public class OracleParallelReadInfo { 12 | private boolean processParallel; 13 | private OracleColumn rangeColumn; 14 | private int numOfBuckets; 15 | public boolean isProcessParallel() { 16 | return processParallel; 17 | } 18 | public void setProcessParallel(boolean processParallel) { 19 | this.processParallel = processParallel; 20 | } 21 | public OracleColumn getRangeColumn() { 22 | return rangeColumn; 23 | } 24 | public void setRangeColumn(OracleColumn rangeColumn) { 25 | this.rangeColumn = rangeColumn; 26 | } 27 | public int getNumOfBuckets() { 28 | return numOfBuckets; 29 | } 30 | public void setNumOfBuckets(int numOfBuckets) { 31 | this.numOfBuckets = numOfBuckets; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/event/SyncError.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.event; 2 | 3 | import org.bson.BsonDocument; 4 | import org.bson.BsonDocumentWrapper; 5 | import org.bson.codecs.configuration.CodecRegistry; 6 | import org.bson.conversions.Bson; 7 | 8 | /** 9 | * Bean to hold process Errors 10 | * 11 | * @author pnilayam 12 | * 13 | */ 14 | public class SyncError extends Exception implements Bson{ 15 | private static final long serialVersionUID = 7690440940108580397L; 16 | private String threadName; 17 | private String fullStackTrace; 18 | public SyncError() { 19 | super(); 20 | } 21 | public SyncError(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 22 | super(message, cause, enableSuppression, writableStackTrace); 23 | } 24 | public SyncError(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | public SyncError(String message) { 28 | super(message); 29 | } 30 | public SyncError(Throwable cause) { 31 | super(cause); 32 | } 33 | public String getFullStackTrace() { 34 | return fullStackTrace; 35 | } 36 | public void setFullStackTrace(String fullStackTrace) { 37 | this.fullStackTrace = fullStackTrace; 38 | } 39 | public String getThreadName() { 40 | return threadName; 41 | } 42 | public void setThreadName(String threadName) { 43 | this.threadName = threadName; 44 | } 45 | @Override 46 | public BsonDocument toBsonDocument(Class arg0, CodecRegistry codecRegistry) { 47 | return new BsonDocumentWrapper(this, codecRegistry.get(SyncError.class)); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/event/SyncMarker.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.event; 2 | 3 | import java.util.Date; 4 | 5 | import org.bson.BsonDocument; 6 | import org.bson.BsonDocumentWrapper; 7 | import org.bson.codecs.configuration.CodecRegistry; 8 | import org.bson.conversions.Bson; 9 | 10 | /** 11 | * Bean to hold Sync Event status and details 12 | * 13 | * @author pnilayam 14 | * 15 | */ 16 | public class SyncMarker implements Bson { 17 | private volatile boolean allRowsFetchedFromDb; 18 | private int rowsRead; 19 | private int rowsDumped; 20 | private int totalRows; 21 | private Date startTime; 22 | private Date endTime; 23 | private volatile boolean failed; 24 | 25 | public boolean isFailed() { 26 | return failed; 27 | } 28 | 29 | public void setFailed(boolean failed) { 30 | this.failed = failed; 31 | } 32 | 33 | public Date getStartTime() { 34 | return startTime; 35 | } 36 | 37 | public void setStartTime(Date startTime) { 38 | this.startTime = startTime; 39 | } 40 | 41 | public Date getEndTime() { 42 | return endTime; 43 | } 44 | 45 | public void setEndTime(Date endTime) { 46 | this.endTime = endTime; 47 | } 48 | 49 | public SyncMarker() { 50 | failed=false; 51 | totalRows = -1; 52 | } 53 | 54 | public synchronized boolean isAllRowsFetchedFromDb() { 55 | return allRowsFetchedFromDb; 56 | } 57 | 58 | public synchronized void setAllRowsFetchedFromDb(boolean allRowsFetchedFromDb) { 59 | this.allRowsFetchedFromDb = allRowsFetchedFromDb; 60 | } 61 | 62 | public synchronized int getRowsRead() { 63 | return rowsRead; 64 | } 65 | 66 | public synchronized void setRowsRead(int rowsRead) { 67 | this.rowsRead = rowsRead; 68 | } 69 | 70 | public synchronized int getRowsDumped() { 71 | return rowsDumped; 72 | } 73 | 74 | public synchronized void setRowsDumped(int rowsDumped) { 75 | this.rowsDumped = rowsDumped; 76 | } 77 | 78 | public int getTotalRows() { 79 | return totalRows; 80 | } 81 | 82 | public void setTotalRows(int totalRows) { 83 | this.totalRows = totalRows; 84 | } 85 | 86 | public synchronized void addToRowsDumped(int rowsDumped) { 87 | this.rowsDumped += rowsDumped; 88 | } 89 | 90 | @Override 91 | public BsonDocument toBsonDocument(Class arg0, CodecRegistry codecRegistry) { 92 | return new BsonDocumentWrapper(this, codecRegistry.get(SyncMarker.class)); 93 | } 94 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/event/range/DataRange.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.event.range; 2 | 3 | public class DataRange { 4 | private String rangeAttribute; 5 | private Object upperLimit; 6 | private Object lowerLimit; 7 | private boolean isUpperLimitInclusive; 8 | private boolean isLowerLimitInclusive; 9 | public String getRangeAttribute() { 10 | return rangeAttribute; 11 | } 12 | public void setRangeAttribute(String rangeAttribute) { 13 | this.rangeAttribute = rangeAttribute; 14 | } 15 | public Object getUpperLimit() { 16 | return upperLimit; 17 | } 18 | public void setUpperLimit(Object upperLimit) { 19 | this.upperLimit = upperLimit; 20 | } 21 | public Object getLowerLimit() { 22 | return lowerLimit; 23 | } 24 | public void setLowerLimit(Object lowerLimit) { 25 | this.lowerLimit = lowerLimit; 26 | } 27 | public boolean isUpperLimitInclusive() { 28 | return isUpperLimitInclusive; 29 | } 30 | public void setUpperLimitInclusive(boolean isUpperLimitInclusive) { 31 | this.isUpperLimitInclusive = isUpperLimitInclusive; 32 | } 33 | public boolean isLowerLimitInclusive() { 34 | return isLowerLimitInclusive; 35 | } 36 | public void setLowerLimitInclusive(boolean isLowerLimitInclusive) { 37 | this.isLowerLimitInclusive = isLowerLimitInclusive; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/event/range/DateRangeDivisor.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.event.range; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | public class DateRangeDivisor extends RangeDivisor { 8 | 9 | public DateRangeDivisor(int numOfBuckets, Date minValue, Date maxValue) { 10 | super(numOfBuckets, minValue, maxValue); 11 | } 12 | 13 | @Override 14 | public List generateRangeList() { 15 | List rangeList= new ArrayList(); 16 | long diff= maxValue.getTime()-minValue.getTime(); 17 | long factor = diff/numOfBuckets; 18 | long currentMin=maxValue.getTime(); 19 | for(int i=0;i { 7 | 8 | public IntRangeDivisor(int numOfBuckets, Integer minValue, Integer maxValue) { 9 | super(numOfBuckets, minValue, maxValue); 10 | } 11 | 12 | @Override 13 | public List generateRangeList() { 14 | List rangeList= new ArrayList(); 15 | //int diff = maxValue-minValue; 16 | //int factor = diff/numOfBuckets; 17 | int currentMin=minValue; 18 | /*for(int i=0;i{ 6 | protected int numOfBuckets; 7 | protected T minValue; 8 | protected T maxValue; 9 | public int getNumOfBuckets() { 10 | return numOfBuckets; 11 | } 12 | public RangeDivisor(int numOfBuckets, T minValue, T maxValue) { 13 | super(); 14 | this.numOfBuckets = numOfBuckets; 15 | this.minValue = minValue; 16 | this.maxValue = maxValue; 17 | } 18 | public void setNumOfBuckets(int numOfBuckets) { 19 | this.numOfBuckets = numOfBuckets; 20 | } 21 | public T getMinValue() { 22 | return minValue; 23 | } 24 | public void setMinValue(T minValue) { 25 | this.minValue = minValue; 26 | } 27 | public T getMaxValue() { 28 | return maxValue; 29 | } 30 | public void setMaxValue(T maxValue) { 31 | this.maxValue = maxValue; 32 | } 33 | public abstract List generateRangeList(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/event/range/RangeDivisorFactory.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.event.range; 2 | 3 | import java.util.Date; 4 | 5 | public class RangeDivisorFactory { 6 | @SuppressWarnings("rawtypes") 7 | public static RangeDivisor getRangeDivisor(Object minValue, Object maxValue , int numOfBuckets, String columnType) { 8 | RangeDivisor rangeDivisor=null; 9 | if("NUMBER".equalsIgnoreCase(columnType)){ 10 | rangeDivisor=new IntRangeDivisor(numOfBuckets, (Integer)minValue, (Integer)maxValue); 11 | }else if ("DATE".equalsIgnoreCase(columnType)) { 12 | rangeDivisor=new DateRangeDivisor(numOfBuckets, (Date)minValue, (Date)maxValue); 13 | } 14 | return rangeDivisor; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/job/EventJob.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.job; 2 | 3 | import org.apache.log4j.Logger; 4 | import org.quartz.JobExecutionContext; 5 | import org.quartz.JobExecutionException; 6 | import org.springframework.scheduling.quartz.QuartzJobBean; 7 | 8 | public class EventJob extends QuartzJobBean{ 9 | private static Logger logger = Logger.getLogger(EventJob.class); 10 | @Override 11 | protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException { 12 | logger.debug("Migration Job triggered"); 13 | NodeBalancer.INSTANCE.process(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/job/NodeMonitorJob.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.job; 2 | 3 | import org.apache.log4j.Logger; 4 | import org.quartz.JobExecutionContext; 5 | import org.quartz.JobExecutionException; 6 | import org.springframework.scheduling.quartz.QuartzJobBean; 7 | 8 | import com.cisco.app.dbmigrator.migratorapp.logging.dao.SyncNodeDao; 9 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncNode; 10 | import com.cisco.app.dbmigrator.migratorapp.mail.Mailer; 11 | 12 | public class NodeMonitorJob extends QuartzJobBean{ 13 | //private final Logger logger = Logger.getLogger(NodeMonitorJob.class); 14 | 15 | @Override 16 | protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException { 17 | //logger.info("Node Monitor Thread Triggered"); 18 | NodeMonitorUtil.INSTANCE.getFailedNode(); 19 | } 20 | 21 | private enum NodeMonitorUtil{ 22 | INSTANCE; 23 | private static final long timeDuration = 300000; 24 | private static final Logger logger = Logger.getLogger(NodeMonitorUtil.class); 25 | private final SyncNodeDao nodeDao; 26 | 27 | private NodeMonitorUtil(){ 28 | nodeDao = new SyncNodeDao(); 29 | } 30 | 31 | public void getFailedNode(){ 32 | SyncNode failedNode = nodeDao.getFailedNode(System.currentTimeMillis()-timeDuration); 33 | if(failedNode==null){ 34 | logger.info("All nodes are fine"); 35 | }else{ 36 | logger.info("Failed Host name "+ failedNode.getHostName()); 37 | logger.info("Failed AppId "+ failedNode.getUUID()); 38 | if(failedNode.getFailureTime()==0){ 39 | failedNode.setFailureTime(failedNode.getLastPingTime()); 40 | } 41 | Mailer.sendMailForFailedNode(failedNode); 42 | } 43 | 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/job/SyncStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.cisco.app.dbmigrator.migratorapp.core.job; 5 | 6 | /** 7 | * @author pnilayam 8 | * 9 | */ 10 | public enum SyncStatus { 11 | STATUS; 12 | public static final String PENDING = "PENDING"; 13 | public static final String FAILED = "FAILED"; 14 | public static final String APPROVED = "APPROVED"; 15 | public static final String IN_PROGRESS = "INPROGRESS"; 16 | public static final String COMPLETE = "COMPLETE"; 17 | public static final String PREPARING = "PREPARING"; 18 | public static final String CANCELLED ="CANCELLED"; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/map/MapType.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.map; 2 | 3 | public enum MapType { 4 | OrclToMongo,MongoToOrcl,OrclToMongoGridFs; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/map/MongoToOracleMap.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.map; 2 | 3 | import java.util.List; 4 | 5 | import org.bson.BsonDocument; 6 | import org.bson.BsonDocumentWrapper; 7 | import org.bson.codecs.configuration.CodecRegistry; 8 | 9 | import com.cisco.app.dbmigrator.migratorapp.core.meta.oracle.NodeGroup; 10 | 11 | public class MongoToOracleMap extends SyncMap{ 12 | //private Map nodeGroupMap; 13 | private List rootNode; 14 | private String collectionName; 15 | 16 | /*public Map getNodeGroupMap() { 17 | return nodeGroupMap; 18 | } 19 | public void setNodeGroupMap(Map nodeGroupMap) { 20 | this.nodeGroupMap = nodeGroupMap; 21 | }*/ 22 | public String getCollectionName() { 23 | return collectionName; 24 | } 25 | /** 26 | * @return the rootNode 27 | */ 28 | public List getRootNode() { 29 | return rootNode; 30 | } 31 | /** 32 | * @param rootNode the rootNode to set 33 | */ 34 | public void setRootNode(List rootNode) { 35 | this.rootNode = rootNode; 36 | } 37 | public void setCollectionName(String collectionName) { 38 | this.collectionName = collectionName; 39 | } 40 | @Override 41 | public BsonDocument toBsonDocument(Class arg0, CodecRegistry codecRegistry) { 42 | return new BsonDocumentWrapper(this, codecRegistry.get(MongoToOracleMap.class)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/map/OracleToMongoGridFsMap.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.map; 2 | 3 | import java.util.Map; 4 | 5 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleColumn; 6 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleTable; 7 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents.SQLFilters; 8 | 9 | public class OracleToMongoGridFsMap extends SyncMap{ 10 | private Map metaAttributes; 11 | private OracleTable streamTable; 12 | private String collectionName; 13 | private OracleColumn fileNameColumn; 14 | private OracleColumn inputStreamColumn; 15 | private SQLFilters filters; 16 | public SQLFilters getFilters() { 17 | return filters; 18 | } 19 | public void setFilters(SQLFilters filters) { 20 | this.filters = filters; 21 | } 22 | public Map getMetaAttributes() { 23 | return metaAttributes; 24 | } 25 | public void setMetaAttributes(Map metaAttributes) { 26 | this.metaAttributes = metaAttributes; 27 | } 28 | public OracleTable getStreamTable() { 29 | return streamTable; 30 | } 31 | public void setStreamTable(OracleTable streamTable) { 32 | this.streamTable = streamTable; 33 | } 34 | public OracleColumn getInputStreamColumn() { 35 | return inputStreamColumn; 36 | } 37 | public void setInputStreamColumn(OracleColumn inputStreamColumn) { 38 | this.inputStreamColumn = inputStreamColumn; 39 | } 40 | public String getCollectionName() { 41 | return collectionName; 42 | } 43 | public void setCollectionName(String collectionName) { 44 | this.collectionName = collectionName; 45 | } 46 | public OracleColumn getFileNameColumn() { 47 | return fileNameColumn; 48 | } 49 | public void setFileNameColumn(OracleColumn fileNameColumn) { 50 | this.fileNameColumn = fileNameColumn; 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/map/OracleToMongoMap.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.map; 2 | 3 | import org.bson.BsonDocument; 4 | import org.bson.BsonDocumentWrapper; 5 | import org.bson.codecs.configuration.CodecRegistry; 6 | 7 | import com.cisco.app.dbmigrator.migratorapp.core.meta.mongo.MongoObject; 8 | 9 | public class OracleToMongoMap extends SyncMap{ 10 | private MongoObject mapObject; 11 | 12 | public MongoObject getMapObject() { 13 | return mapObject; 14 | } 15 | public void setMapObject(MongoObject mapObject) { 16 | this.mapObject = mapObject; 17 | } 18 | @Override 19 | public BsonDocument toBsonDocument(Class arg0, CodecRegistry codecRegistry) { 20 | return new BsonDocumentWrapper(this, codecRegistry.get(OracleToMongoMap.class)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/map/SyncMap.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.map; 2 | 3 | import java.util.Date; 4 | 5 | import org.bson.BsonDocument; 6 | import org.bson.BsonDocumentWrapper; 7 | import org.bson.codecs.configuration.CodecRegistry; 8 | import org.bson.conversions.Bson; 9 | import org.bson.types.ObjectId; 10 | 11 | public abstract class SyncMap implements Bson{ 12 | protected ObjectId mapId; 13 | protected String mapName; 14 | protected String createdBy; 15 | protected String approvedBy; 16 | protected Date createdOn; 17 | protected Date approvedOn; 18 | protected String comments; 19 | protected String sourceDbName; 20 | protected String sourceUserName; 21 | protected String targetDbName; 22 | protected String targetUserName; 23 | protected MapType mapType; 24 | public ObjectId getMapId() { 25 | return mapId; 26 | } 27 | public void setMapId(ObjectId mapId) { 28 | this.mapId = mapId; 29 | } 30 | public String getMapName() { 31 | return mapName; 32 | } 33 | public void setMapName(String mapName) { 34 | this.mapName = mapName; 35 | } 36 | public String getCreatedBy() { 37 | return createdBy; 38 | } 39 | public void setCreatedBy(String createdBy) { 40 | this.createdBy = createdBy; 41 | } 42 | public String getApprovedBy() { 43 | return approvedBy; 44 | } 45 | public void setApprovedBy(String approvedBy) { 46 | this.approvedBy = approvedBy; 47 | } 48 | public Date getCreatedOn() { 49 | return createdOn; 50 | } 51 | public void setCreatedOn(Date createdOn) { 52 | this.createdOn = createdOn; 53 | } 54 | public Date getApprovedOn() { 55 | return approvedOn; 56 | } 57 | public void setApprovedOn(Date approvedOn) { 58 | this.approvedOn = approvedOn; 59 | } 60 | public String getComments() { 61 | return comments; 62 | } 63 | public void setComments(String comments) { 64 | this.comments = comments; 65 | } 66 | public String getSourceDbName() { 67 | return sourceDbName; 68 | } 69 | public void setSourceDbName(String sourceDbName) { 70 | this.sourceDbName = sourceDbName; 71 | } 72 | public String getTargetDbName() { 73 | return targetDbName; 74 | } 75 | public void setTargetDbName(String targetDbName) { 76 | this.targetDbName = targetDbName; 77 | } 78 | public String getSourceUserName() { 79 | return sourceUserName; 80 | } 81 | public void setSourceUserName(String sourceUserName) { 82 | this.sourceUserName = sourceUserName; 83 | } 84 | public String getTargetUserName() { 85 | return targetUserName; 86 | } 87 | public void setTargetUserName(String targetUserName) { 88 | this.targetUserName = targetUserName; 89 | } 90 | public MapType getMapType() { 91 | return mapType; 92 | } 93 | public void setMapType(MapType mapType) { 94 | this.mapType = mapType; 95 | } 96 | public void setMapType(String mapType) { 97 | this.mapType = MapType.valueOf(mapType); 98 | } 99 | @Override 100 | public BsonDocument toBsonDocument(Class arg0, CodecRegistry codecRegistry) { 101 | return new BsonDocumentWrapper(this, codecRegistry.get(SyncMap.class)); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/es/EsAttribute.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.es; 2 | 3 | public class EsAttribute implements EsEntity{ 4 | 5 | private String attributeName; 6 | private String attributeType; 7 | public String getAttributeName() { 8 | return attributeName; 9 | } 10 | public void setAttributeName(String attributeName) { 11 | this.attributeName = attributeName; 12 | } 13 | public String getAttributeType() { 14 | return attributeType; 15 | } 16 | public void setAttributeType(String attributeType) { 17 | this.attributeType = attributeType; 18 | } 19 | @Override 20 | public String getEntityType() { 21 | return String.valueOf(EsEntityTypes.EsAttribute); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/es/EsEntity.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.es; 2 | 3 | public interface EsEntity { 4 | public String getEntityType(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/es/EsEntityTypes.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.es; 2 | 3 | public enum EsEntityTypes { 4 | EsAttribute,EsObject; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/es/EsMngAttrMapper.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.es; 2 | 3 | import com.cisco.app.dbmigrator.migratorapp.core.meta.mongo.MongoAttribute; 4 | 5 | public class EsMngAttrMapper { 6 | private MongoAttribute mongoAttribute; 7 | private EsAttribute esAttribute; 8 | private String collectionName; 9 | public String getCollectionName() { 10 | return collectionName; 11 | } 12 | public void setCollectionName(String collectionName) { 13 | this.collectionName = collectionName; 14 | } 15 | public MongoAttribute getMongoAttribute() { 16 | return mongoAttribute; 17 | } 18 | public void setMongoAttribute(MongoAttribute mongoAttribute) { 19 | this.mongoAttribute = mongoAttribute; 20 | } 21 | public EsAttribute getEsAttribute() { 22 | return esAttribute; 23 | } 24 | public void setEsAttribute(EsAttribute esAttribute) { 25 | this.esAttribute = esAttribute; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/es/EsObject.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.es; 2 | 3 | import java.util.List; 4 | 5 | public class EsObject implements EsEntity { 6 | private String esObjectName; 7 | private List esMngAttrMap; 8 | private List mappedCollectionInfoList; 9 | public String getEsObjectName() { 10 | return esObjectName; 11 | } 12 | 13 | public void setEsObjectName(String esObjectName) { 14 | this.esObjectName = esObjectName; 15 | } 16 | 17 | public List getMappedCollectionInfoList() { 18 | return mappedCollectionInfoList; 19 | } 20 | 21 | public void setMappedCollectionInfoList(List mappedCollectionInfoList) { 22 | this.mappedCollectionInfoList = mappedCollectionInfoList; 23 | } 24 | 25 | public List getEsMngAttrMap() { 26 | return esMngAttrMap; 27 | } 28 | 29 | public void setEsMngAttrMap(List esMngAttrMap) { 30 | this.esMngAttrMap = esMngAttrMap; 31 | } 32 | 33 | @Override 34 | public String getEntityType() { 35 | return String.valueOf(EsEntityTypes.EsObject); 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/es/MappedCollectionInfo.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.es; 2 | 3 | import org.bson.conversions.Bson; 4 | 5 | public class MappedCollectionInfo { 6 | private String collectionName; 7 | private String attributeName; 8 | private String attributeType; 9 | private Bson filters; 10 | public String getCollectionName() { 11 | return collectionName; 12 | } 13 | public void setCollectionName(String collectionName) { 14 | this.collectionName = collectionName; 15 | } 16 | public String getAttributeName() { 17 | return attributeName; 18 | } 19 | public void setAttributeName(String attributeName) { 20 | this.attributeName = attributeName; 21 | } 22 | public String getAttributeType() { 23 | return attributeType; 24 | } 25 | public void setAttributeType(String attributeType) { 26 | this.attributeType = attributeType; 27 | } 28 | public Bson getFilters() { 29 | return filters; 30 | } 31 | public void setFilters(Bson filters) { 32 | this.filters = filters; 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/es/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | /** 5 | * @author pnilayam 6 | * 7 | */ 8 | package com.cisco.app.dbmigrator.migratorapp.core.meta.es; -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/mongo/MongoAttribute.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.mongo; 2 | 3 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleColumn; 4 | 5 | public class MongoAttribute implements MongoEntity{ 6 | private String attributeName; 7 | private MongoAttributeType attributeType; 8 | private OracleColumn mappedOracleColumn; 9 | private boolean isIdentifier; 10 | private String defaultValue; 11 | public String getAttributeName() { 12 | return attributeName; 13 | } 14 | public boolean isIdentifier() { 15 | return isIdentifier; 16 | } 17 | public void setIdentifier(boolean isIdentifier) { 18 | this.isIdentifier = isIdentifier; 19 | } 20 | public void setAttributeName(String attributeName) { 21 | this.attributeName = attributeName; 22 | } 23 | public String getAttributeType() { 24 | return String.valueOf(attributeType); 25 | } 26 | public void setAttributeType(String attributeType) { 27 | this.attributeType = MongoAttributeType.valueOf(attributeType); 28 | } 29 | public void setAttributeType(MongoAttributeType attributeType) { 30 | this.attributeType = attributeType; 31 | } 32 | public OracleColumn getMappedOracleColumn() { 33 | return mappedOracleColumn; 34 | } 35 | public void setMappedOracleColumn(OracleColumn mappedOracleColumn) { 36 | this.mappedOracleColumn = mappedOracleColumn; 37 | } 38 | public String getDefaultValue() { 39 | return defaultValue; 40 | } 41 | public void setDefaultValue(String defaultValue) { 42 | this.defaultValue = defaultValue; 43 | } 44 | @Override 45 | public String toString() { 46 | return "MongoAttribute [attributeName=" + attributeName + ", attributeType=" + attributeType 47 | + ", mappedOracleColumn=" + mappedOracleColumn + "]"; 48 | } 49 | @Override 50 | public String getEntityType() { 51 | return String.valueOf(attributeType); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/mongo/MongoAttributeType.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.mongo; 2 | 3 | public enum MongoAttributeType { 4 | AUTO,ARRAY,STRING,NUMBER,BOOLEAN,NULL,DATE,COLLECTION,ROOT,B_ARRAY,INTEGER,DOUBLE,OBJECTID,LONG,DOCUMENT,BINARY; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/mongo/MongoEntity.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.mongo; 2 | 3 | public interface MongoEntity{ 4 | public String getEntityType(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/mongo/MongoGridData.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.mongo; 2 | 3 | import java.io.InputStream; 4 | 5 | import org.bson.Document; 6 | 7 | public class MongoGridData { 8 | private Document gridMetaData; 9 | private String fileName; 10 | private InputStream is; 11 | private byte [] binData; 12 | public byte[] getBinData() { 13 | return binData; 14 | } 15 | public void setBinData(byte[] binData) { 16 | this.binData = binData; 17 | } 18 | public Document getGridMetaData() { 19 | return gridMetaData; 20 | } 21 | public void setGridMetaData(Document gridMetaData) { 22 | this.gridMetaData = gridMetaData; 23 | } 24 | public InputStream getIs() { 25 | return is; 26 | } 27 | public void setIs(InputStream is) { 28 | this.is = is; 29 | } 30 | public String getFileName() { 31 | return fileName; 32 | } 33 | public void setFileName(String fileName) { 34 | this.fileName = fileName; 35 | } 36 | @Override 37 | public String toString() { 38 | return "MongoGridData [gridMetaData=" + String.valueOf(gridMetaData) + ", fileName=" + fileName + "]"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/meta/mongo/MongoObject.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.meta.mongo; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleColumn; 7 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleTable; 8 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents.SQLFilters; 9 | 10 | /** 11 | * @author pnilayam 12 | * 13 | */ 14 | public class MongoObject implements MongoEntity{ 15 | private String collectionName; 16 | private String collectionType; 17 | private List sourceTables; 18 | private List attributes; 19 | private List identifierList; 20 | private SQLFilters filters; 21 | private List referencedColumns; 22 | public List getReferencedColumns() { 23 | return referencedColumns; 24 | } 25 | public void setReferencedColumns(List referencedColumns) { 26 | this.referencedColumns = referencedColumns; 27 | } 28 | public String getCollectionType() { 29 | return collectionType; 30 | } 31 | public void setCollectionType(String collectionType) { 32 | this.collectionType = collectionType; 33 | } 34 | public List getIdentifierList() { 35 | return identifierList; 36 | } 37 | public void setIdentifierList(List identifierList) { 38 | this.identifierList = identifierList; 39 | } 40 | public SQLFilters getFilters() { 41 | return filters; 42 | } 43 | public void setFilters(SQLFilters filters) { 44 | this.filters = filters; 45 | } 46 | public String getCollectionName() { 47 | return collectionName; 48 | } 49 | public void setCollectionName(String collectionName) { 50 | this.collectionName = collectionName; 51 | } 52 | public List getSourceTables() { 53 | return sourceTables; 54 | } 55 | public void setSourceTables(List sourceTables) { 56 | this.sourceTables = sourceTables; 57 | } 58 | public List getAttributes() { 59 | initializeAttributeList(); 60 | return attributes; 61 | } 62 | public void setAttributes(List attributes) { 63 | this.attributes = attributes; 64 | } 65 | private void initializeAttributeList(){ 66 | if(attributes==null){ 67 | attributes=new ArrayList(); 68 | } 69 | } 70 | private void initializeIdentifierList(){ 71 | if(identifierList==null){ 72 | identifierList=new ArrayList(); 73 | } 74 | } 75 | public void addEntity(MongoEntity entity) { 76 | initializeAttributeList(); 77 | this.attributes.add(entity); 78 | } 79 | public void addIdentifierEntity(MongoEntity entity) { 80 | initializeIdentifierList(); 81 | this.identifierList.add(entity); 82 | } 83 | @Override 84 | public String getEntityType() { 85 | return collectionType; 86 | } 87 | public void addReferencedColumns(OracleColumn column) { 88 | initializeReferencedColumns(); 89 | this.referencedColumns.add(column); 90 | } 91 | private void initializeReferencedColumns(){ 92 | if(referencedColumns==null){ 93 | referencedColumns=new ArrayList(); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/thread/MngToOrclReader.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.thread; 2 | 3 | import java.util.concurrent.BlockingQueue; 4 | 5 | import org.bson.Document; 6 | 7 | import com.cisco.app.dbmigrator.migratorapp.utilities.cache.DBCacheManager; 8 | import com.mongodb.Block; 9 | import com.mongodb.client.FindIterable; 10 | import com.mongodb.client.MongoCollection; 11 | 12 | public class MngToOrclReader implements Runnable { 13 | 14 | private BlockingQueue dataBuffer; 15 | private final String mongoDbName; 16 | private final String mongoUserName; 17 | private final String collectionName; 18 | private final int batchSize; 19 | 20 | public MngToOrclReader(BlockingQueue dataBuffer, String mongoDbName, String mongoUserName, 21 | String collectionName, int batchSize) { 22 | super(); 23 | this.dataBuffer = dataBuffer; 24 | this.mongoDbName = mongoDbName; 25 | this.mongoUserName = mongoUserName; 26 | this.collectionName = collectionName; 27 | this.batchSize = batchSize; 28 | } 29 | 30 | @Override 31 | public void run() { 32 | System.out.println("Reader started"); 33 | MongoCollection collection = DBCacheManager.INSTANCE.getCachedMongoPool(mongoDbName, mongoUserName) 34 | .getDatabase(mongoDbName).getCollection(collectionName); 35 | FindIterable it = collection.find().batchSize(batchSize); 36 | it.forEach(new Block() { 37 | @Override 38 | public void apply(Document t) { 39 | System.out.println("Document read " + t); 40 | try { 41 | dataBuffer.put(t); 42 | } catch (InterruptedException e) { 43 | // TODO Auto-generated catch block 44 | e.printStackTrace(); 45 | } 46 | } 47 | }); 48 | } 49 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/core/thread/SyncOperation.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.core.thread; 2 | 3 | public enum SyncOperation { 4 | i, u, d; 5 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/interceptor/HttpAuthInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.interceptor; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | import javax.servlet.http.HttpSession; 8 | 9 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 10 | 11 | import com.cisco.app.dbmigrator.migratorapp.config.SyncConfig; 12 | import com.cisco.app.dbmigrator.migratorapp.constants.SyncConstants; 13 | import com.cisco.app.dbmigrator.migratorapp.logging.dao.SyncUserDao; 14 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncUser; 15 | 16 | public class HttpAuthInterceptor extends HandlerInterceptorAdapter { 17 | Logger logger = Logger.getLogger("HttpAuthInterceptor"); 18 | 19 | @Override 20 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 21 | HttpSession httpSession=request.getSession(false); 22 | if(httpSession==null){ 23 | logger.info("Creating a new Http session"); 24 | httpSession=request.getSession(true); 25 | } 26 | String userId= SyncConfig.INSTANCE.getProperty("SYNC_USER");//request.getRemoteUser(); 27 | SyncUser user = (SyncUser) httpSession.getAttribute(SyncConstants.USER); 28 | if(user==null){ 29 | SyncUserDao userDao = new SyncUserDao(); 30 | user = userDao.getUser(userId); 31 | httpSession.setAttribute(SyncConstants.USER, user); 32 | } 33 | return true; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/MngToOrclEventCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.event.MongoToOracleEvent; 15 | 16 | public class MngToOrclEventCodec implements CollectibleCodec { 17 | private Codec documentCodec; 18 | 19 | public MngToOrclEventCodec(Codec documentCodec) { 20 | super(); 21 | this.documentCodec = documentCodec; 22 | } 23 | 24 | @Override 25 | public void encode(BsonWriter writer, MongoToOracleEvent event, EncoderContext encoderContext) { 26 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 27 | Document document =encoder.encodeSyncEvent(event); 28 | documentCodec.encode(writer, document, encoderContext); 29 | } 30 | 31 | @Override 32 | public Class getEncoderClass() { 33 | return MongoToOracleEvent.class; 34 | } 35 | 36 | @Override 37 | public MongoToOracleEvent decode(BsonReader reader, DecoderContext decoderContext) { 38 | Document document = documentCodec.decode(reader, decoderContext); 39 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 40 | MongoToOracleEvent event = (MongoToOracleEvent) decoder.decodeSyncEvent(document); 41 | return event; 42 | } 43 | 44 | @Override 45 | public boolean documentHasId(MongoToOracleEvent event) { 46 | return event.getEventId() != null; 47 | } 48 | 49 | @Override 50 | public MongoToOracleEvent generateIdIfAbsentFromDocument(MongoToOracleEvent event) { 51 | if (!documentHasId(event)) { 52 | event.setEventId(new ObjectId()); 53 | } 54 | return event; 55 | } 56 | 57 | @Override 58 | public BsonValue getDocumentId(MongoToOracleEvent event) { 59 | return new BsonObjectId(event.getEventId()); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/MngToOrclMapCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.map.MongoToOracleMap; 15 | 16 | public class MngToOrclMapCodec implements CollectibleCodec { 17 | 18 | private Codec documentCodec; 19 | 20 | 21 | public MngToOrclMapCodec(Codec documentCodec) { 22 | super(); 23 | this.documentCodec = documentCodec; 24 | } 25 | 26 | @Override 27 | public void encode(BsonWriter writer, MongoToOracleMap map, EncoderContext encoderContext) { 28 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 29 | Document document = encoder.encodeSyncMap(map); 30 | documentCodec.encode(writer, document, encoderContext); 31 | } 32 | 33 | @Override 34 | public Class getEncoderClass() { 35 | return MongoToOracleMap.class; 36 | } 37 | 38 | @Override 39 | public MongoToOracleMap decode(BsonReader reader, DecoderContext decoderContext) { 40 | Document document = documentCodec.decode(reader, decoderContext); 41 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 42 | return (MongoToOracleMap) decoder.decodeSyncMap(document); 43 | } 44 | 45 | @Override 46 | public boolean documentHasId(MongoToOracleMap map) { 47 | return map.getMapId() != null; 48 | } 49 | 50 | @Override 51 | public MongoToOracleMap generateIdIfAbsentFromDocument(MongoToOracleMap map) { 52 | if (!documentHasId(map)) { 53 | map.setMapId(new ObjectId()); 54 | } 55 | return map; 56 | } 57 | 58 | @Override 59 | public BsonValue getDocumentId(MongoToOracleMap map) { 60 | return new BsonObjectId(map.getMapId()); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/MngToOrclSyncEventCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.event.MongoToOracleSyncEvent; 15 | 16 | public class MngToOrclSyncEventCodec implements CollectibleCodec { 17 | private Codec documentCodec; 18 | 19 | public MngToOrclSyncEventCodec(Codec documentCodec) { 20 | super(); 21 | this.documentCodec = documentCodec; 22 | } 23 | 24 | @Override 25 | public void encode(BsonWriter writer, MongoToOracleSyncEvent event, EncoderContext encoderContext) { 26 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 27 | Document document =encoder.encodeSyncEvent(event); 28 | documentCodec.encode(writer, document, encoderContext); 29 | } 30 | 31 | @Override 32 | public Class getEncoderClass() { 33 | return MongoToOracleSyncEvent.class; 34 | } 35 | 36 | @Override 37 | public MongoToOracleSyncEvent decode(BsonReader reader, DecoderContext decoderContext) { 38 | Document document = documentCodec.decode(reader, decoderContext); 39 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 40 | MongoToOracleSyncEvent event = (MongoToOracleSyncEvent) decoder.decodeSyncEvent(document); 41 | return event; 42 | } 43 | 44 | @Override 45 | public boolean documentHasId(MongoToOracleSyncEvent event) { 46 | return event.getEventId() != null; 47 | } 48 | 49 | @Override 50 | public MongoToOracleSyncEvent generateIdIfAbsentFromDocument(MongoToOracleSyncEvent event) { 51 | if (!documentHasId(event)) { 52 | event.setEventId(new ObjectId()); 53 | } 54 | return event; 55 | } 56 | 57 | @Override 58 | public BsonValue getDocumentId(MongoToOracleSyncEvent event) { 59 | return new BsonObjectId(event.getEventId()); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/OrclToMngEventCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.event.OracleToMongoEvent; 15 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncEvent; 16 | 17 | public class OrclToMngEventCodec implements CollectibleCodec { 18 | 19 | private Codec documentCodec; 20 | 21 | public OrclToMngEventCodec(Codec documentCodec) { 22 | super(); 23 | this.documentCodec = documentCodec; 24 | } 25 | 26 | @Override 27 | public void encode(BsonWriter writer, OracleToMongoEvent event, EncoderContext encoderContext) { 28 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 29 | Document document =encoder.encodeSyncEvent(event); 30 | documentCodec.encode(writer, document, encoderContext); 31 | } 32 | 33 | @Override 34 | public Class getEncoderClass() { 35 | return OracleToMongoEvent.class; 36 | } 37 | 38 | @SuppressWarnings("rawtypes") 39 | @Override 40 | public OracleToMongoEvent decode(BsonReader reader, DecoderContext decoderContext) { 41 | Document document = documentCodec.decode(reader, decoderContext); 42 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 43 | SyncEvent event = decoder.decodeSyncEvent(document); 44 | return (OracleToMongoEvent) event; 45 | } 46 | 47 | @Override 48 | public boolean documentHasId(OracleToMongoEvent event) { 49 | return event.getEventId() != null; 50 | } 51 | 52 | @Override 53 | public OracleToMongoEvent generateIdIfAbsentFromDocument(OracleToMongoEvent event) { 54 | if (!documentHasId(event)) { 55 | event.setEventId(new ObjectId()); 56 | } 57 | return event; 58 | } 59 | 60 | @Override 61 | public BsonValue getDocumentId(OracleToMongoEvent event) { 62 | return new BsonObjectId(event.getEventId()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/OrclToMngGridFsEventCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.event.OracleToMongoGridFsEvent; 15 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncEvent; 16 | 17 | public class OrclToMngGridFsEventCodec implements CollectibleCodec { 18 | 19 | private Codec documentCodec; 20 | 21 | public OrclToMngGridFsEventCodec(Codec documentCodec) { 22 | super(); 23 | this.documentCodec = documentCodec; 24 | } 25 | 26 | @Override 27 | public void encode(BsonWriter writer, OracleToMongoGridFsEvent event, EncoderContext encoderContext) { 28 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 29 | Document document =encoder.encodeSyncEvent(event); 30 | documentCodec.encode(writer, document, encoderContext); 31 | } 32 | 33 | @Override 34 | public Class getEncoderClass() { 35 | return OracleToMongoGridFsEvent.class; 36 | } 37 | 38 | @SuppressWarnings("rawtypes") 39 | @Override 40 | public OracleToMongoGridFsEvent decode(BsonReader reader, DecoderContext decoderContext) { 41 | Document document = documentCodec.decode(reader, decoderContext); 42 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 43 | SyncEvent event = decoder.decodeSyncEvent(document); 44 | return (OracleToMongoGridFsEvent) event; 45 | } 46 | 47 | @Override 48 | public boolean documentHasId(OracleToMongoGridFsEvent event) { 49 | return event.getEventId() != null; 50 | } 51 | 52 | @Override 53 | public OracleToMongoGridFsEvent generateIdIfAbsentFromDocument(OracleToMongoGridFsEvent event) { 54 | if (!documentHasId(event)) { 55 | event.setEventId(new ObjectId()); 56 | } 57 | return event; 58 | } 59 | 60 | @Override 61 | public BsonValue getDocumentId(OracleToMongoGridFsEvent event) { 62 | return new BsonObjectId(event.getEventId()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/OrclToMngMapCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.map.OracleToMongoMap; 15 | 16 | public class OrclToMngMapCodec implements CollectibleCodec { 17 | 18 | private Codec documentCodec; 19 | 20 | public OrclToMngMapCodec(Codec documentCodec) { 21 | super(); 22 | this.documentCodec = documentCodec; 23 | } 24 | 25 | @Override 26 | public void encode(BsonWriter writer, OracleToMongoMap map, EncoderContext encoderContext) { 27 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 28 | Document document = encoder.encodeSyncMap(map); 29 | documentCodec.encode(writer, document, encoderContext); 30 | } 31 | 32 | @Override 33 | public Class getEncoderClass() { 34 | return OracleToMongoMap.class; 35 | } 36 | 37 | @Override 38 | public OracleToMongoMap decode(BsonReader reader, DecoderContext decoderContext) { 39 | Document document = documentCodec.decode(reader, decoderContext); 40 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 41 | return (OracleToMongoMap) decoder.decodeSyncMap(document); 42 | } 43 | 44 | @Override 45 | public boolean documentHasId(OracleToMongoMap map) { 46 | return map.getMapId() != null; 47 | } 48 | 49 | @Override 50 | public OracleToMongoMap generateIdIfAbsentFromDocument(OracleToMongoMap map) { 51 | if (!documentHasId(map)) { 52 | map.setMapId(new ObjectId()); 53 | } 54 | return map; 55 | } 56 | 57 | @Override 58 | public BsonValue getDocumentId(OracleToMongoMap map) { 59 | return new BsonObjectId(map.getMapId()); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/OrclToMngSyncEventCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.event.OracleToMongoSyncEvent; 15 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncEvent; 16 | 17 | public class OrclToMngSyncEventCodec implements CollectibleCodec { 18 | private Codec documentCodec; 19 | 20 | public OrclToMngSyncEventCodec(Codec documentCodec) { 21 | super(); 22 | this.documentCodec = documentCodec; 23 | } 24 | 25 | @Override 26 | public void encode(BsonWriter writer, OracleToMongoSyncEvent event, EncoderContext encoderContext) { 27 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 28 | Document document =encoder.encodeSyncEvent(event); 29 | documentCodec.encode(writer, document, encoderContext); 30 | } 31 | 32 | @Override 33 | public Class getEncoderClass() { 34 | return OracleToMongoSyncEvent.class; 35 | } 36 | 37 | @Override 38 | public OracleToMongoSyncEvent decode(BsonReader reader, DecoderContext decoderContext) { 39 | Document document = documentCodec.decode(reader, decoderContext); 40 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 41 | @SuppressWarnings("rawtypes") 42 | SyncEvent event = decoder.decodeSyncEvent(document); 43 | return (OracleToMongoSyncEvent) event; 44 | } 45 | 46 | @Override 47 | public boolean documentHasId(OracleToMongoSyncEvent event) { 48 | return event.getEventId() != null; 49 | } 50 | 51 | @Override 52 | public OracleToMongoSyncEvent generateIdIfAbsentFromDocument(OracleToMongoSyncEvent event) { 53 | if (!documentHasId(event)) { 54 | event.setEventId(new ObjectId()); 55 | } 56 | return event; 57 | } 58 | 59 | @Override 60 | public BsonValue getDocumentId(OracleToMongoSyncEvent event) { 61 | return new BsonObjectId(event.getEventId()); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/OrclToMongoGridFsMapCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.map.OracleToMongoGridFsMap; 15 | 16 | public class OrclToMongoGridFsMapCodec implements CollectibleCodec { 17 | 18 | private Codec documentCodec; 19 | 20 | public OrclToMongoGridFsMapCodec(Codec documentCodec) { 21 | super(); 22 | this.documentCodec = documentCodec; 23 | } 24 | 25 | @Override 26 | public void encode(BsonWriter writer, OracleToMongoGridFsMap map, EncoderContext encoderContext) { 27 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 28 | Document document = encoder.encodeSyncMap(map); 29 | documentCodec.encode(writer, document, encoderContext); 30 | } 31 | 32 | @Override 33 | public Class getEncoderClass() { 34 | return OracleToMongoGridFsMap.class; 35 | } 36 | 37 | @Override 38 | public OracleToMongoGridFsMap decode(BsonReader reader, DecoderContext decoderContext) { 39 | Document document = documentCodec.decode(reader, decoderContext); 40 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 41 | return (OracleToMongoGridFsMap) decoder.decodeSyncMap(document); 42 | } 43 | 44 | @Override 45 | public boolean documentHasId(OracleToMongoGridFsMap map) { 46 | return map.getMapId() != null; 47 | } 48 | 49 | @Override 50 | public OracleToMongoGridFsMap generateIdIfAbsentFromDocument(OracleToMongoGridFsMap map) { 51 | if (!documentHasId(map)) { 52 | map.setMapId(new ObjectId()); 53 | } 54 | return map; 55 | } 56 | 57 | @Override 58 | public BsonValue getDocumentId(OracleToMongoGridFsMap map) { 59 | return new BsonObjectId(map.getMapId()); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncErrorCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.apache.commons.lang3.exception.ExceptionUtils; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonWriter; 6 | import org.bson.Document; 7 | import org.bson.codecs.Codec; 8 | import org.bson.codecs.DecoderContext; 9 | import org.bson.codecs.EncoderContext; 10 | 11 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncError; 12 | 13 | public class SyncErrorCodec implements Codec { 14 | private Codec documentCodec; 15 | 16 | public SyncErrorCodec(Codec documentCodec) { 17 | super(); 18 | this.documentCodec = documentCodec; 19 | } 20 | @Override 21 | public void encode(BsonWriter writer, SyncError error, EncoderContext encoderContext) { 22 | Document document= new Document(); 23 | if(error.getMessage()!=null && !error.getMessage().isEmpty()){ 24 | document.append(SyncAttrs.ERROR_MESSAGE, error.getMessage()); 25 | } 26 | 27 | String fullStackTrace = ExceptionUtils.getStackTrace(error); 28 | if(fullStackTrace!=null && !fullStackTrace.isEmpty()){ 29 | document.append(SyncAttrs.TRACE, fullStackTrace); 30 | } 31 | if(error.getThreadName()!=null && !error.getThreadName().isEmpty()){ 32 | document.append(SyncAttrs.THREAD_NAME, error.getThreadName()); 33 | } 34 | documentCodec.encode(writer, document, encoderContext); 35 | } 36 | 37 | @Override 38 | public Class getEncoderClass() { 39 | return SyncError.class; 40 | } 41 | 42 | @Override 43 | public SyncError decode(BsonReader reader, DecoderContext decoderContext) { 44 | Document document = documentCodec.decode(reader, decoderContext); 45 | SyncError error = new SyncError(document.getString(SyncAttrs.ERROR_MESSAGE)); 46 | error.setThreadName(document.getString(SyncAttrs.THREAD_NAME)); 47 | error.setFullStackTrace(document.getString(SyncAttrs.TRACE)); 48 | return error; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncEventCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncEvent; 15 | 16 | @SuppressWarnings("rawtypes") 17 | public class SyncEventCodec implements CollectibleCodec { 18 | private Codec documentCodec; 19 | 20 | public SyncEventCodec(Codec documentCodec) { 21 | super(); 22 | this.documentCodec = documentCodec; 23 | } 24 | 25 | @Override 26 | public void encode(BsonWriter writer, SyncEvent event, EncoderContext encoderContext) { 27 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 28 | Document document =encoder.encodeSyncEvent(event); 29 | documentCodec.encode(writer, document, encoderContext); 30 | } 31 | 32 | @Override 33 | public Class getEncoderClass() { 34 | return SyncEvent.class; 35 | } 36 | 37 | @Override 38 | public SyncEvent decode(BsonReader reader, DecoderContext decoderContext) { 39 | Document document = documentCodec.decode(reader, decoderContext); 40 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 41 | SyncEvent event = decoder.decodeSyncEvent(document); 42 | return event; 43 | } 44 | 45 | @Override 46 | public boolean documentHasId(SyncEvent event) { 47 | return event.getEventId() != null; 48 | } 49 | 50 | @Override 51 | public SyncEvent generateIdIfAbsentFromDocument(SyncEvent event) { 52 | if (!documentHasId(event)) { 53 | event.setEventId(new ObjectId()); 54 | } 55 | return event; 56 | } 57 | 58 | @Override 59 | public BsonValue getDocumentId(SyncEvent event) { 60 | return new BsonObjectId(event.getEventId()); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncEventGridFsCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.event.OracleToMongoGridFsEvent; 15 | 16 | public class SyncEventGridFsCodec implements CollectibleCodec { 17 | 18 | private Codec documentCodec; 19 | 20 | public SyncEventGridFsCodec(Codec documentCodec) { 21 | super(); 22 | this.documentCodec = documentCodec; 23 | } 24 | 25 | @Override 26 | public void encode(BsonWriter writer, OracleToMongoGridFsEvent event, EncoderContext encoderContext) { 27 | SyncMapAndEventGridFsEncoder encoder = new SyncMapAndEventGridFsEncoder(); 28 | Document document =encoder.encodeSyncEvent(event); 29 | documentCodec.encode(writer, document, encoderContext); 30 | } 31 | 32 | @Override 33 | public Class getEncoderClass() { 34 | return OracleToMongoGridFsEvent.class; 35 | } 36 | 37 | @Override 38 | public OracleToMongoGridFsEvent decode(BsonReader reader, DecoderContext decoderContext) { 39 | Document document = documentCodec.decode(reader, decoderContext); 40 | SyncMapAndEventGridFsDecoder decoder = new SyncMapAndEventGridFsDecoder(); 41 | OracleToMongoGridFsEvent event = decoder.decodeSyncEvent(document); 42 | return event; 43 | } 44 | 45 | @Override 46 | public boolean documentHasId(OracleToMongoGridFsEvent event) { 47 | return event.getEventId() != null; 48 | } 49 | 50 | @Override 51 | public OracleToMongoGridFsEvent generateIdIfAbsentFromDocument(OracleToMongoGridFsEvent event) { 52 | if (!documentHasId(event)) { 53 | event.setEventId(new ObjectId()); 54 | } 55 | return event; 56 | } 57 | 58 | @Override 59 | public BsonValue getDocumentId(OracleToMongoGridFsEvent event) { 60 | return new BsonObjectId(event.getEventId()); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncMapCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.map.SyncMap; 15 | 16 | public class SyncMapCodec implements CollectibleCodec { 17 | private Codec documentCodec; 18 | 19 | public SyncMapCodec(Codec documentCodec) { 20 | super(); 21 | this.documentCodec = documentCodec; 22 | } 23 | 24 | @Override 25 | public void encode(BsonWriter writer, SyncMap map, EncoderContext encoderContext) { 26 | SyncMapAndEventEncoder encoder = new SyncMapAndEventEncoder(); 27 | Document document= encoder.encodeSyncMap(map); 28 | documentCodec.encode(writer, document, encoderContext); 29 | } 30 | 31 | @Override 32 | public Class getEncoderClass() { 33 | return SyncMap.class; 34 | } 35 | 36 | @Override 37 | public SyncMap decode(BsonReader reader, DecoderContext decoderContext) { 38 | Document document = documentCodec.decode(reader, decoderContext); 39 | SyncMapAndEventDecoder decoder = new SyncMapAndEventDecoder(); 40 | return decoder.decodeSyncMap(document); 41 | } 42 | 43 | @Override 44 | public boolean documentHasId(SyncMap map) { 45 | return map.getMapId() != null; 46 | } 47 | 48 | @Override 49 | public SyncMap generateIdIfAbsentFromDocument(SyncMap map) { 50 | if (!documentHasId(map)) { 51 | map.setMapId(new ObjectId()); 52 | } 53 | return map; 54 | } 55 | 56 | @Override 57 | public BsonValue getDocumentId(SyncMap map) { 58 | return new BsonObjectId(map.getMapId()); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncMapGridFsCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | import org.bson.types.ObjectId; 13 | 14 | import com.cisco.app.dbmigrator.migratorapp.core.map.OracleToMongoGridFsMap; 15 | 16 | public class SyncMapGridFsCodec implements CollectibleCodec { 17 | 18 | private Codec documentCodec; 19 | 20 | public SyncMapGridFsCodec(Codec documentCodec) { 21 | super(); 22 | this.documentCodec = documentCodec; 23 | } 24 | 25 | @Override 26 | public void encode(BsonWriter writer, OracleToMongoGridFsMap map, EncoderContext encoderContext) { 27 | SyncMapAndEventGridFsEncoder encoder = new SyncMapAndEventGridFsEncoder(); 28 | Document document= encoder.encodeSyncMap(map); 29 | documentCodec.encode(writer, document, encoderContext); 30 | } 31 | 32 | @Override 33 | public Class getEncoderClass() { 34 | return OracleToMongoGridFsMap.class; 35 | } 36 | 37 | @Override 38 | public OracleToMongoGridFsMap decode(BsonReader reader, DecoderContext decoderContext) { 39 | Document document = documentCodec.decode(reader, decoderContext); 40 | SyncMapAndEventGridFsDecoder decoder = new SyncMapAndEventGridFsDecoder(); 41 | return decoder.decodeSyncMap(document); 42 | } 43 | 44 | @Override 45 | public boolean documentHasId(OracleToMongoGridFsMap map) { 46 | return map.getMapId() != null; 47 | } 48 | 49 | @Override 50 | public OracleToMongoGridFsMap generateIdIfAbsentFromDocument(OracleToMongoGridFsMap map) { 51 | if (!documentHasId(map)) { 52 | map.setMapId(new ObjectId()); 53 | } 54 | return map; 55 | } 56 | 57 | @Override 58 | public BsonValue getDocumentId(OracleToMongoGridFsMap map) { 59 | return new BsonObjectId(map.getMapId()); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncMarkerCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonReader; 4 | import org.bson.BsonWriter; 5 | import org.bson.Document; 6 | import org.bson.codecs.Codec; 7 | import org.bson.codecs.DecoderContext; 8 | import org.bson.codecs.EncoderContext; 9 | 10 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncMarker; 11 | 12 | public class SyncMarkerCodec implements Codec { 13 | private Codec documentCodec; 14 | public SyncMarkerCodec(Codec documentCodec) { 15 | super(); 16 | this.documentCodec = documentCodec; 17 | } 18 | @Override 19 | public void encode(BsonWriter writer, SyncMarker marker, EncoderContext encoderContext) { 20 | Document document = new Document(); 21 | if(marker.getStartTime()!=null){ 22 | document.append(SyncAttrs.START_TIME, marker.getStartTime()); 23 | } 24 | document.append(SyncAttrs.ROWS_READ, marker.getRowsRead()); 25 | if(marker.isAllRowsFetchedFromDb()){ 26 | document.append(SyncAttrs.ALL_ROWS_FETCHED, marker.isAllRowsFetchedFromDb()); 27 | } 28 | document.append(SyncAttrs.ROWS_DUMPED, marker.getRowsDumped()); 29 | document.append(SyncAttrs.TOTAL_ROWS, marker.getTotalRows()); 30 | if(marker.getEndTime()!=null){ 31 | document.append(SyncAttrs.END_TIME, marker.getEndTime()); 32 | } 33 | documentCodec.encode(writer, document, encoderContext); 34 | } 35 | 36 | @Override 37 | public Class getEncoderClass() { 38 | return SyncMarker.class; 39 | } 40 | 41 | @Override 42 | public SyncMarker decode(BsonReader reader, DecoderContext decoderContext) { 43 | Document document = documentCodec.decode(reader, decoderContext); 44 | SyncMarker marker = new SyncMarker(); 45 | marker.setAllRowsFetchedFromDb(document.getBoolean(SyncAttrs.ALL_ROWS_FETCHED, false)); 46 | marker.setTotalRows(document.getInteger(SyncAttrs.TOTAL_ROWS, -1)); 47 | marker.setRowsDumped(document.getInteger(SyncAttrs.ROWS_DUMPED, 0)); 48 | marker.setRowsRead(document.getInteger(SyncAttrs.ROWS_READ, 0)); 49 | marker.setStartTime(document.getDate(SyncAttrs.START_TIME)); 50 | marker.setEndTime(document.getDate(SyncAttrs.END_TIME)); 51 | return marker; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncNodeCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.BsonObjectId; 4 | import org.bson.BsonReader; 5 | import org.bson.BsonValue; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.CollectibleCodec; 10 | import org.bson.codecs.DecoderContext; 11 | import org.bson.codecs.EncoderContext; 12 | 13 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncNode; 14 | 15 | 16 | public class SyncNodeCodec implements CollectibleCodec { 17 | 18 | public Codec documentCodec; 19 | public SyncNodeCodec(Codec documentCodec) { 20 | super(); 21 | this.documentCodec = documentCodec; 22 | } 23 | @Override 24 | public void encode(BsonWriter writer, SyncNode nodeMapper, EncoderContext encoderContext) { 25 | Document document = SyncNodeEncoder.encodeNode(nodeMapper); 26 | documentCodec.encode(writer, document, encoderContext); 27 | } 28 | @Override 29 | public Class getEncoderClass() { 30 | return SyncNode.class; 31 | } 32 | @Override 33 | public SyncNode decode(BsonReader reader, DecoderContext decoderContext) { 34 | Document document = documentCodec.decode(reader, decoderContext); 35 | SyncNode nodeMapper = SyncNodeDecoder.decodeNode(document); 36 | return nodeMapper; 37 | } 38 | @Override 39 | public boolean documentHasId(SyncNode nodeMapper) { 40 | return nodeMapper.getId()== null; 41 | } 42 | @Override 43 | public SyncNode generateIdIfAbsentFromDocument(SyncNode nodeMapper) { 44 | return nodeMapper; 45 | } 46 | @Override 47 | public BsonValue getDocumentId(SyncNode nodeMapper) { 48 | return new BsonObjectId(nodeMapper.getId()); 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncNodeDecoder.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import org.bson.Document; 6 | import org.bson.types.ObjectId; 7 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncNode; 8 | 9 | public class SyncNodeDecoder { 10 | 11 | @SuppressWarnings("unchecked") 12 | public static SyncNode decodeNode(Document document) { 13 | SyncNode nodeMapper=new SyncNode(); 14 | nodeMapper.setId(document.getObjectId(SyncAttrs.ID)); 15 | nodeMapper.setConcurrencyLevel(document.getInteger(SyncAttrs.CON_LEVEL,10)); 16 | nodeMapper.setHostName(document.getString(SyncAttrs.HOST)); 17 | nodeMapper.setJvmName(document.getString(SyncAttrs.JVM)); 18 | nodeMapper.setNodeName(document.getString(SyncAttrs.NODE)); 19 | nodeMapper.setState(document.getString(SyncAttrs.STATE)); 20 | nodeMapper.setLifeCycle(document.getString(SyncAttrs.LIFE_CYCLE)); 21 | if(document.get(SyncAttrs.TOTAL_HEAP_SIZE)!=null){ 22 | nodeMapper.setTotalHeapSize(document.getLong(SyncAttrs.TOTAL_HEAP_SIZE)); 23 | } 24 | if(document.get(SyncAttrs.USED_HEAP_SIZE)!=null){ 25 | nodeMapper.setUsedHeapSize(document.getLong(SyncAttrs.USED_HEAP_SIZE)); 26 | } 27 | nodeMapper.setEventList((List) document.get(SyncAttrs.ACTIVE_EVENTS)); 28 | List eventTypes = (List) document.get(SyncAttrs.EVENT_TYPES); 29 | nodeMapper.setEventTypes(eventTypes!=null?eventTypes :new ArrayList(1)); 30 | nodeMapper.setSystemEvents((List) document.get(SyncAttrs.SYSTEM_EVENTS)); 31 | nodeMapper.setUUID(document.getString(SyncAttrs.UUID)); 32 | if(document.get(SyncAttrs.FAILURE_TIME)!=null){ 33 | nodeMapper.setFailureTime(document.getLong(SyncAttrs.FAILURE_TIME)); 34 | }else{ 35 | nodeMapper.setFailureTime(0L); 36 | } 37 | if(document.get(SyncAttrs.LAST_PING_TIME)!=null){ 38 | nodeMapper.setLastPingTime(document.getLong(SyncAttrs.LAST_PING_TIME)); 39 | }else{ 40 | nodeMapper.setLastPingTime(0L); 41 | } 42 | return nodeMapper; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncNodeDetailsCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import org.bson.BsonReader; 6 | import org.bson.BsonWriter; 7 | import org.bson.Document; 8 | import org.bson.codecs.Codec; 9 | import org.bson.codecs.DecoderContext; 10 | import org.bson.codecs.EncoderContext; 11 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncEvent; 12 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncNode; 13 | import com.cisco.app.dbmigrator.migratorapp.logging.entity.SyncNodeDetails; 14 | 15 | public class SyncNodeDetailsCodec implements Codec { 16 | 17 | private Codec documentCodec; 18 | 19 | public SyncNodeDetailsCodec(Codec documentCodec) { 20 | super(); 21 | this.documentCodec = documentCodec; 22 | } 23 | 24 | @Override 25 | public void encode(BsonWriter bsonWriter, SyncNodeDetails nodeAndEvent, EncoderContext context) { 26 | Document document = new Document(); 27 | if (nodeAndEvent.getNode() != null) { 28 | document.append("node", nodeAndEvent.getNode()); 29 | } 30 | if (nodeAndEvent.getEvent() != null) { 31 | document.append("events", nodeAndEvent.getEvent()); 32 | } 33 | documentCodec.encode(bsonWriter, document, context); 34 | } 35 | 36 | @Override 37 | public Class getEncoderClass() { 38 | return SyncNodeDetails.class; 39 | } 40 | 41 | @SuppressWarnings("rawtypes") 42 | @Override 43 | public SyncNodeDetails decode(BsonReader bsonReader, DecoderContext context) { 44 | Document document = documentCodec.decode(bsonReader, context); 45 | SyncNodeDetails nodeAndEvent = new SyncNodeDetails(); 46 | SyncNode node = SyncNodeDecoder.decodeNode((Document) document.get("node")); 47 | nodeAndEvent.setNode(node); 48 | SyncEvent event = null; 49 | List eventList = new ArrayList(); 50 | SyncMapAndEventDecoder eventDecoder = new SyncMapAndEventDecoder(); 51 | @SuppressWarnings("unchecked") 52 | List list = (List) document.get("events"); 53 | for(Document doc : list){ 54 | event = eventDecoder.decodeSyncEvent(doc); 55 | eventList.add(event); 56 | } 57 | nodeAndEvent.setEvent(eventList); 58 | return nodeAndEvent; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncNodeEncoder.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import org.bson.Document; 4 | 5 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncNode; 6 | 7 | public class SyncNodeEncoder { 8 | 9 | public static Document encodeNode(SyncNode nodeMapper){ 10 | Document document = new Document(); 11 | if(nodeMapper.getId()!=null){ 12 | document.append(SyncAttrs.ID, nodeMapper.getId()); 13 | } 14 | if(nodeMapper.getHostName()!=null && !nodeMapper.getHostName().isEmpty()){ 15 | document.append(SyncAttrs.HOST, nodeMapper.getHostName()); 16 | } 17 | if(nodeMapper.getNodeName()!=null && !nodeMapper.getNodeName().isEmpty()){ 18 | document.append(SyncAttrs.NODE, nodeMapper.getNodeName()); 19 | } 20 | if(nodeMapper.getJvmName()!=null && !nodeMapper.getJvmName().isEmpty()){ 21 | document.append(SyncAttrs.JVM, nodeMapper.getJvmName()); 22 | } 23 | if(nodeMapper.getLifeCycle()!=null && !nodeMapper.getLifeCycle().isEmpty()){ 24 | document.append(SyncAttrs.LIFE_CYCLE, nodeMapper.getLifeCycle()); 25 | } 26 | if(nodeMapper.getState()!=null && !nodeMapper.getState().isEmpty()){ 27 | document.append(SyncAttrs.STATE, nodeMapper.getState()); 28 | } 29 | if(nodeMapper.getConcurrencyLevel()!=0){ 30 | document.append(SyncAttrs.CON_LEVEL, nodeMapper.getConcurrencyLevel()); 31 | } 32 | if(nodeMapper.getTotalHeapSize()!=0){ 33 | document.append(SyncAttrs.TOTAL_HEAP_SIZE, nodeMapper.getTotalHeapSize()); 34 | } 35 | if(nodeMapper.getUsedHeapSize()!=0){ 36 | document.append(SyncAttrs.USED_HEAP_SIZE, nodeMapper.getUsedHeapSize()); 37 | } 38 | if(nodeMapper.getEventList()!=null){ 39 | document.append(SyncAttrs.ACTIVE_EVENTS, nodeMapper.getEventList()); 40 | } 41 | if(nodeMapper.getEventTypes()!=null){ 42 | document.append(SyncAttrs.EVENT_TYPES, nodeMapper.getEventTypes()); 43 | } 44 | if(nodeMapper.getSystemEvents()!=null){ 45 | document.append(SyncAttrs.SYSTEM_EVENTS, nodeMapper.getSystemEvents()); 46 | } 47 | if(nodeMapper.getUUID()!=null){ 48 | document.append(SyncAttrs.UUID, nodeMapper.getUUID()); 49 | } 50 | if(nodeMapper.getFailureTime()!=0){ 51 | document.append(SyncAttrs.FAILURE_TIME, nodeMapper.getFailureTime()); 52 | } 53 | document.append(SyncAttrs.LAST_PING_TIME, System.currentTimeMillis()); 54 | return document; 55 | } 56 | public static String getNodeJson(SyncNode node) { 57 | return SyncNodeEncoder.encodeNode(node).toJson(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/codecs/SyncUserDetailCodec.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.codecs; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import java.util.Set; 6 | import java.util.UUID; 7 | import java.util.logging.Logger; 8 | 9 | import org.bson.BsonReader; 10 | import org.bson.BsonString; 11 | import org.bson.BsonValue; 12 | import org.bson.BsonWriter; 13 | import org.bson.Document; 14 | import org.bson.codecs.Codec; 15 | import org.bson.codecs.CollectibleCodec; 16 | import org.bson.codecs.DecoderContext; 17 | import org.bson.codecs.EncoderContext; 18 | 19 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncUser; 20 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncUser.UserDetailAttributes; 21 | 22 | public class SyncUserDetailCodec implements CollectibleCodec { 23 | private Codec documentCodec; 24 | Logger logger =Logger.getLogger(this.getClass().getSimpleName()); 25 | public SyncUserDetailCodec(Codec documentCodec) { 26 | super(); 27 | this.documentCodec = documentCodec; 28 | } 29 | @Override 30 | public void encode(BsonWriter writer, SyncUser user, EncoderContext encoderContext) { 31 | logger.info("Start of Encode method"); 32 | Document document = new Document(); 33 | if (user.getUserid()!=null && !user.getUserid().isEmpty()){ 34 | document.append(String.valueOf(UserDetailAttributes._id), user.getUserid()); 35 | } 36 | if(user.getSourceDbMap()!=null && !user.getSourceDbMap().isEmpty()){ 37 | document.append(String.valueOf(UserDetailAttributes.sourceDbMap), user.getSourceDbMap()); 38 | } 39 | if(user.getTargetDbMap()!=null && !user.getTargetDbMap().isEmpty()){ 40 | document.append(String.valueOf(UserDetailAttributes.targetDbMap), user.getTargetDbMap()); 41 | } 42 | if(user.getUserRoles()!=null && !user.getUserRoles().isEmpty()){ 43 | document.append("roles", user.getUserRoles()); 44 | } 45 | documentCodec.encode(writer, document, encoderContext); 46 | logger.info("Encoder completed. Document formed is \n"+document); 47 | } 48 | @Override 49 | public Class getEncoderClass() { 50 | return SyncUser.class; 51 | } 52 | @SuppressWarnings("unchecked") 53 | @Override 54 | public SyncUser decode(BsonReader reader, DecoderContext decoderContext) { 55 | logger.info("Start of decode method"); 56 | SyncUser user = new SyncUser(); 57 | Document document = documentCodec.decode(reader, decoderContext); 58 | user.setUserid(document.getString(String.valueOf(UserDetailAttributes._id))); 59 | user.setSourceDbMap((Map>) document.get(String.valueOf(UserDetailAttributes.sourceDbMap))); 60 | user.setTargetDbMap((Map>) document.get(String.valueOf(UserDetailAttributes.targetDbMap))); 61 | user.setUserRoles((List) document.get("roles")); 62 | logger.info("Decode completed. Object formed is "+user.toString()); 63 | return user; 64 | } 65 | @Override 66 | public boolean documentHasId(SyncUser user) { 67 | return user.getUserid()==null; 68 | } 69 | @Override 70 | public SyncUser generateIdIfAbsentFromDocument(SyncUser user) { 71 | if (!documentHasId(user)) { 72 | user.setUserid((UUID.randomUUID().toString())); 73 | } 74 | return user; 75 | } 76 | @Override 77 | public BsonValue getDocumentId(SyncUser user) { 78 | return new BsonString(user.getUserid()); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/connection/ApplicationCollections.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.connection; 2 | 3 | public enum ApplicationCollections { 4 | SyncUserSession, SyncUserDetail, SyncConnectionInfo, SyncNodeMapping,SyncMappings, SyncEvents , O2MSyncEventLog; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/dao/O2MEventLogDao.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.ApplicationCollections; 6 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.MongoConnection; 7 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.O2MSyncEventLog; 8 | import com.mongodb.client.MongoCollection; 9 | 10 | public class O2MEventLogDao { 11 | MongoCollection eventLog = MongoConnection.INSTANCE.getMongoDataBase() 12 | .getCollection(String.valueOf(ApplicationCollections.O2MSyncEventLog), O2MSyncEventLog.class); 13 | 14 | public void writeData(List eventLogList){ 15 | if(eventLogList==null || eventLogList.isEmpty()){ 16 | return; 17 | } 18 | eventLog.insertMany(eventLogList); 19 | } 20 | 21 | public void logEvent(O2MSyncEventLog eventInfo){ 22 | eventLog.insertOne(eventInfo); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/dao/SyncConnectionDao.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.dao; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bson.types.ObjectId; 7 | 8 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.ApplicationCollections; 9 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.MongoConnection; 10 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncConnectionInfo; 11 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncConnectionInfo.ConnectionInfoAttributes; 12 | import com.mongodb.client.MongoCollection; 13 | import com.mongodb.client.model.Filters; 14 | import com.mongodb.client.model.FindOneAndReplaceOptions; 15 | import com.mongodb.client.model.FindOneAndUpdateOptions; 16 | import com.mongodb.client.model.Projections; 17 | import com.mongodb.client.model.ReturnDocument; 18 | import com.mongodb.client.model.Updates; 19 | 20 | public class SyncConnectionDao { 21 | MongoCollection connectionInfo = MongoConnection.INSTANCE.getMongoDataBase() 22 | .getCollection(String.valueOf(ApplicationCollections.SyncConnectionInfo), SyncConnectionInfo.class); 23 | 24 | public SyncConnectionInfo getConnection(String dbName, String dbUserName) { 25 | return connectionInfo.find( 26 | Filters.and(Filters.eq(String.valueOf(ConnectionInfoAttributes.dbName), dbName), 27 | Filters.eq(String.valueOf(ConnectionInfoAttributes.userName), dbUserName)), 28 | SyncConnectionInfo.class).first(); 29 | } 30 | 31 | public SyncConnectionInfo updateConnection(SyncConnectionInfo connInfo) { 32 | if(connInfo.getConnectionId() == null){ 33 | connInfo.setConnectionId(new ObjectId()); 34 | } 35 | return connectionInfo.findOneAndReplace( 36 | Filters.eq(String.valueOf(ConnectionInfoAttributes._id), connInfo.getConnectionId()), connInfo, 37 | new FindOneAndReplaceOptions().returnDocument(ReturnDocument.AFTER).upsert(true)); 38 | } 39 | 40 | public List getConnectionDetails() { 41 | return connectionInfo.find().projection(Projections.include(String.valueOf(ConnectionInfoAttributes.dbName),String.valueOf(ConnectionInfoAttributes.userName),String.valueOf(ConnectionInfoAttributes.dbType))) 42 | .into(new ArrayList()); 43 | } 44 | 45 | public void getConnetionById(ObjectId id){ 46 | connectionInfo.find(Filters.eq(String.valueOf(ConnectionInfoAttributes._id), id)).first(); 47 | } 48 | 49 | public void deleteConnetion(ObjectId id){ 50 | connectionInfo.deleteOne(Filters.eq(String.valueOf(ConnectionInfoAttributes._id), id)); 51 | } 52 | 53 | public List getPassword() { 54 | return connectionInfo.find().projection(Projections.include(String.valueOf(ConnectionInfoAttributes._id),String.valueOf(ConnectionInfoAttributes.password))) 55 | .into(new ArrayList()); 56 | } 57 | 58 | public void setEncryptedPassword(ObjectId id , byte[] pass) { 59 | connectionInfo.findOneAndUpdate( 60 | Filters.and(Filters.eq(String.valueOf(ConnectionInfoAttributes._id), id)), 61 | Updates.set(String.valueOf(ConnectionInfoAttributes.password), pass), 62 | new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)); 63 | } 64 | 65 | public SyncConnectionInfo searchConnection(String dbName,String userName,String dbType){ 66 | return connectionInfo.find(Filters.and(Filters.eq(String.valueOf(ConnectionInfoAttributes.dbName), dbName), 67 | Filters.eq(String.valueOf(ConnectionInfoAttributes.userName), userName),Filters.eq(String.valueOf(ConnectionInfoAttributes.dbType), dbType)),SyncConnectionInfo.class 68 | ).first(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/dao/SyncMapDao.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.dao; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bson.types.ObjectId; 7 | 8 | import com.cisco.app.dbmigrator.migratorapp.core.map.SyncMap; 9 | import com.cisco.app.dbmigrator.migratorapp.logging.codecs.SyncAttrs; 10 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.ApplicationCollections; 11 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.MongoConnection; 12 | import com.mongodb.client.MongoCollection; 13 | import com.mongodb.client.model.Filters; 14 | import com.mongodb.client.model.FindOneAndReplaceOptions; 15 | import com.mongodb.client.model.Projections; 16 | import com.mongodb.client.model.ReturnDocument; 17 | import com.mongodb.client.model.Sorts; 18 | 19 | public class SyncMapDao{ 20 | MongoCollection syncMappings = MongoConnection.INSTANCE.getMongoDataBase() 21 | .getCollection(String.valueOf(ApplicationCollections.SyncMappings), SyncMap.class); 22 | 23 | public SyncMap saveMapping(SyncMap map) { 24 | // TODO : check why this is needed 25 | if (map.getMapId() == null) { 26 | map.setMapId(new ObjectId()); 27 | } 28 | return syncMappings.findOneAndReplace(Filters.eq(SyncAttrs.ID, map.getMapId()), map, 29 | new FindOneAndReplaceOptions().returnDocument(ReturnDocument.AFTER).upsert(true)); 30 | } 31 | 32 | public SyncMap getMapping(ObjectId mappingId) { 33 | return syncMappings.find(Filters.eq(SyncAttrs.ID, mappingId)).first(); 34 | } 35 | 36 | public List getAllMapping() { 37 | List mapList = new ArrayList(); 38 | syncMappings.find().projection(Projections.exclude(SyncAttrs.MAP_OBJECT)).sort(Sorts.descending(SyncAttrs.CREATED_ON)).into(mapList); 39 | return mapList; 40 | } 41 | 42 | public void deleteMapping(ObjectId objectId) { 43 | syncMappings.deleteOne(Filters.eq(SyncAttrs.ID, objectId)); 44 | } 45 | 46 | public List getMappingByMapType(String mapType) { 47 | List mapList = new ArrayList(); 48 | syncMappings.find(Filters.eq(SyncAttrs.MAP_TYPE, mapType)).projection(Projections.exclude(SyncAttrs.MAP_OBJECT)).sort(Sorts.descending(SyncAttrs.CREATED_ON)).into(mapList); 49 | return mapList; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/dao/SyncNodeDao.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.dao; 2 | 3 | import org.apache.log4j.Logger; 4 | import org.bson.conversions.Bson; 5 | 6 | import com.cisco.app.dbmigrator.migratorapp.config.SyncConfig; 7 | import com.cisco.app.dbmigrator.migratorapp.constants.SyncConstants; 8 | import com.cisco.app.dbmigrator.migratorapp.logging.codecs.SyncAttrs; 9 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.ApplicationCollections; 10 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.MongoConnection; 11 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncNode; 12 | import com.mongodb.client.MongoCollection; 13 | import com.mongodb.client.model.Filters; 14 | import com.mongodb.client.model.FindOneAndReplaceOptions; 15 | import com.mongodb.client.model.FindOneAndUpdateOptions; 16 | import com.mongodb.client.model.ReturnDocument; 17 | import com.mongodb.client.model.Updates; 18 | 19 | public class SyncNodeDao { 20 | 21 | private final Logger logger = Logger.getLogger(getClass()); 22 | MongoCollection syncNodeMapping = MongoConnection.INSTANCE.getMongoDataBase() 23 | .getCollection(String.valueOf(ApplicationCollections.SyncNodeMapping), SyncNode.class); 24 | 25 | public SyncNode updateNodeDetails(SyncNode nodeMapper) { 26 | return syncNodeMapping.findOneAndReplace(Filters.eq(SyncAttrs.ID, nodeMapper.getId()), nodeMapper, 27 | new FindOneAndReplaceOptions().returnDocument(ReturnDocument.AFTER).upsert(true)); 28 | } 29 | 30 | public SyncNode getNodeDetails(SyncNode nodeMapper) { 31 | Bson filter = Filters.eq(SyncAttrs.UUID, nodeMapper.getUUID()); 32 | logger.info("Getting node with filter " + filter); 33 | return syncNodeMapping.findOneAndUpdate(filter, Updates.unset(SyncAttrs.FAILURE_TIME), 34 | new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)); 35 | } 36 | 37 | public SyncNode getFailedNode(long lastPingTime) { 38 | SyncNode failedNode = syncNodeMapping.findOneAndUpdate( 39 | Filters.and(Filters.lte(SyncAttrs.LAST_PING_TIME, lastPingTime), 40 | Filters.eq(SyncAttrs.LIFE_CYCLE, SyncConfig.INSTANCE.getDbProperty(SyncConstants.LIFE))), 41 | Updates.set(SyncAttrs.LAST_PING_TIME, System.currentTimeMillis()), 42 | new FindOneAndUpdateOptions().upsert(false).returnDocument(ReturnDocument.BEFORE)); 43 | if (failedNode != null && failedNode.getFailureTime() == 0) { 44 | syncNodeMapping.findOneAndUpdate(Filters.eq(SyncAttrs.ID, failedNode.getId()), 45 | Updates.set(SyncAttrs.FAILURE_TIME, failedNode.getLastPingTime())); 46 | } 47 | return failedNode; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/dao/SyncNodeDetailsDao.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.dao; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | import org.bson.Document; 8 | 9 | import com.cisco.app.dbmigrator.migratorapp.logging.codecs.SyncAttrs; 10 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.ApplicationCollections; 11 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.MongoConnection; 12 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncNode; 13 | import com.cisco.app.dbmigrator.migratorapp.logging.entity.SyncNodeDetails; 14 | import com.mongodb.client.MongoCollection; 15 | import com.mongodb.client.model.Aggregates; 16 | import com.mongodb.client.model.Filters; 17 | import com.mongodb.client.model.UnwindOptions; 18 | 19 | public class SyncNodeDetailsDao { 20 | 21 | MongoCollection migrationNodeMapping = MongoConnection.INSTANCE.getMongoDataBase() 22 | .getCollection(String.valueOf(ApplicationCollections.SyncNodeMapping), SyncNode.class); 23 | 24 | public List getNodeDetails(String lifeCycle) { 25 | UnwindOptions options = new UnwindOptions(); 26 | options.preserveNullAndEmptyArrays(true); 27 | Document group = new Document("$group", 28 | new Document(SyncAttrs.ID, new Document("_id", "$_id").append("host","$host").append("node","$node").append("state","$state") 29 | .append("concurrencyLevel","$concurrencyLevel").append("totalHeapSize", "$totalHeapSize") 30 | .append("usedHeapSize", "$usedHeapSize").append("lifeCycle", "$lifeCycle")) 31 | .append("eventArr", new Document("$addToSet", "$event_docs"))); 32 | return migrationNodeMapping.aggregate(Arrays.asList(Aggregates.match(Filters.eq(SyncAttrs.LIFE_CYCLE,lifeCycle)), 33 | Aggregates.unwind("$activeEvents",options), 34 | Aggregates.lookup("SyncEvents", "activeEvents", "_id", "event_docs"), 35 | Aggregates.unwind("$event_docs", options), 36 | group,Aggregates.project(new Document("node", "$_id").append("events","$eventArr").append("_id", false))), SyncNodeDetails.class) 37 | .into(new ArrayList()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/dao/SyncUserDao.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.dao; 2 | 3 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.ApplicationCollections; 4 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.MongoConnection; 5 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncUser; 6 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncUser.UserDetailAttributes; 7 | import com.mongodb.client.MongoCollection; 8 | import com.mongodb.client.model.Filters; 9 | import com.mongodb.client.model.FindOneAndReplaceOptions; 10 | import com.mongodb.client.model.ReturnDocument; 11 | 12 | public class SyncUserDao { 13 | MongoCollection userDetailsCollection = MongoConnection.INSTANCE 14 | .getMongoDataBase().getCollection(String.valueOf(ApplicationCollections.SyncUserDetail), 15 | SyncUser.class); 16 | 17 | public SyncUser getUser(String userId) { 18 | return userDetailsCollection.find( 19 | Filters.eq(String.valueOf(UserDetailAttributes._id), userId), 20 | SyncUser.class).first(); 21 | } 22 | 23 | public SyncUser updateUser(SyncUser user) { 24 | return userDetailsCollection.findOneAndReplace( 25 | Filters.eq(String.valueOf(UserDetailAttributes._id),user.getUserid()),user, 26 | new FindOneAndReplaceOptions().returnDocument(ReturnDocument.AFTER) 27 | .upsert(true)); 28 | } 29 | 30 | public void deleteUser(String userId){ 31 | userDetailsCollection.deleteOne(Filters.eq(String.valueOf(UserDetailAttributes._id),userId)); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/dao/SyncUserSessionDao.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.dao; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.ApplicationCollections; 7 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.MongoConnection; 8 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncUserSession; 9 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncUserSession.SessionAttributes; 10 | import com.mongodb.client.MongoCollection; 11 | import com.mongodb.client.model.Filters; 12 | import com.mongodb.client.model.FindOneAndReplaceOptions; 13 | import com.mongodb.client.model.ReturnDocument; 14 | import com.mongodb.client.model.Sorts; 15 | 16 | public class SyncUserSessionDao { 17 | MongoCollection userSessionCollection = MongoConnection.INSTANCE.getMongoDataBase() 18 | .getCollection(String.valueOf(ApplicationCollections.SyncUserSession), SyncUserSession.class); 19 | 20 | public SyncUserSession saveSession(SyncUserSession userSession) { 21 | return userSessionCollection.findOneAndReplace( 22 | Filters.eq(String.valueOf(SessionAttributes._id), userSession.getSessionId()), userSession, 23 | new FindOneAndReplaceOptions().returnDocument(ReturnDocument.AFTER).upsert(true)); 24 | } 25 | 26 | public List getAllSessions(String userId) { 27 | List sessionList = new ArrayList(); 28 | return userSessionCollection.find(Filters.eq(String.valueOf(SessionAttributes.userid), userId)) 29 | .into(sessionList); 30 | } 31 | 32 | public SyncUserSession getLastSession(String userId) { 33 | return userSessionCollection.find(Filters.eq(String.valueOf(SessionAttributes.userid), userId)) 34 | .sort(Sorts.descending(String.valueOf(SessionAttributes.loginTime))).limit(1).first(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/entities/SyncConnectionInfo.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.entities; 2 | 3 | import java.util.Map; 4 | 5 | import org.bson.BsonDocument; 6 | import org.bson.BsonDocumentWrapper; 7 | import org.bson.codecs.configuration.CodecRegistry; 8 | import org.bson.conversions.Bson; 9 | import org.bson.types.ObjectId; 10 | 11 | public class SyncConnectionInfo implements Bson{ 12 | private ObjectId connectionId; 13 | private String connectionName; 14 | private String dbType; 15 | private String dbName; 16 | private String userName; 17 | private String password; 18 | private Map hostToPortMap; 19 | private String url; 20 | private Map esSettings; 21 | public Map getEsSettings() { 22 | return esSettings; 23 | } 24 | public void setEsSettings(Map esSettings) { 25 | this.esSettings = esSettings; 26 | } 27 | /** 28 | * @return the url 29 | */ 30 | public String getUrl() { 31 | return url; 32 | } 33 | /** 34 | * @param url the url to set 35 | */ 36 | public void setUrl(String url) { 37 | this.url = url; 38 | } 39 | public enum ConnectionInfoAttributes{ 40 | _id,connectionName,isDefaultConnection,dbType,dbName,userName,password,hostToPortMap,host,port,url; 41 | } 42 | 43 | public ObjectId getConnectionId() { 44 | return connectionId; 45 | } 46 | public void setConnectionId(ObjectId connectionId) { 47 | this.connectionId = connectionId; 48 | } 49 | public String getConnectionName() { 50 | return connectionName; 51 | } 52 | public void setConnectionName(String connectionName) { 53 | this.connectionName = connectionName; 54 | } 55 | public String getDbType() { 56 | return dbType; 57 | } 58 | public void setDbType(String dbType) { 59 | this.dbType = dbType; 60 | } 61 | public String getDbName() { 62 | return dbName; 63 | } 64 | public void setDbName(String dbName) { 65 | this.dbName = dbName; 66 | } 67 | public String getUserName() { 68 | return userName; 69 | } 70 | public void setUserName(String userName) { 71 | this.userName = userName; 72 | } 73 | public String getPassword() { 74 | return password; 75 | } 76 | public void setPassword(String password) { 77 | this.password = password; 78 | } 79 | public Map getHostToPortMap() { 80 | return hostToPortMap; 81 | } 82 | public void setHostToPortMap(Map hostToPortMap) { 83 | this.hostToPortMap = hostToPortMap; 84 | } 85 | @Override 86 | public BsonDocument toBsonDocument(Class arg0, 87 | CodecRegistry codecRegistry) { 88 | System.out.println("toBsonDocument called"); 89 | return new BsonDocumentWrapper(this, 90 | codecRegistry.get(SyncConnectionInfo.class)); 91 | } 92 | @Override 93 | public String toString(){ 94 | StringBuilder builder = new StringBuilder("{ "); 95 | builder.append(String.valueOf(ConnectionInfoAttributes._id)).append(connectionId).append(","); 96 | builder.append(String.valueOf(ConnectionInfoAttributes.connectionName)).append(connectionName).append(","); 97 | builder.append(String.valueOf(ConnectionInfoAttributes.dbType)).append(dbType); 98 | builder.append(String.valueOf(ConnectionInfoAttributes.dbName)).append(dbName).append(","); 99 | builder.append(String.valueOf(ConnectionInfoAttributes.userName)).append(userName); 100 | return builder.toString(); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/entities/SyncUser.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.entities; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import java.util.Set; 6 | 7 | import org.bson.BsonDocument; 8 | import org.bson.BsonDocumentWrapper; 9 | import org.bson.codecs.configuration.CodecRegistry; 10 | import org.bson.conversions.Bson; 11 | 12 | public class SyncUser implements Bson{ 13 | public enum UserDetailAttributes{ 14 | _id,lastLoginTime,savedSourceDbList,savedTargetDbList,sourceDbMap,targetDbMap,roles; 15 | } 16 | private String userid; 17 | private Map> sourceDbMap; 18 | private Map> targetDbMap; 19 | private List userRoles; 20 | public Map> getSourceDbMap() { 21 | return sourceDbMap; 22 | } 23 | public void setSourceDbMap(Map> sourceDbMap) { 24 | this.sourceDbMap = sourceDbMap; 25 | } 26 | public Map> getTargetDbMap() { 27 | return targetDbMap; 28 | } 29 | public void setTargetDbMap(Map> targetDbMap) { 30 | this.targetDbMap = targetDbMap; 31 | } 32 | public String getUserid() { 33 | return userid; 34 | } 35 | public void setUserid(String userid) { 36 | this.userid = userid; 37 | } 38 | public List getUserRoles() { 39 | return userRoles; 40 | } 41 | public void setUserRoles(List userRoles) { 42 | this.userRoles = userRoles; 43 | } 44 | @Override 45 | public BsonDocument toBsonDocument(Class arg0, 46 | CodecRegistry codecRegistry) { 47 | return new BsonDocumentWrapper(this, 48 | codecRegistry.get(SyncUser.class)); 49 | } 50 | @Override 51 | public String toString(){ 52 | StringBuilder builder = new StringBuilder("{ "); 53 | builder.append(String.valueOf(UserDetailAttributes._id)).append(userid).append(","); 54 | builder.append(String.valueOf(sourceDbMap)).append(","); 55 | builder.append(String.valueOf(targetDbMap)).append(","); 56 | builder.append(String.valueOf(userRoles)); 57 | builder.append(" }"); 58 | return builder.toString(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/entities/SyncUserSession.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.entities; 2 | 3 | import java.util.Date; 4 | 5 | import org.bson.BsonDocument; 6 | import org.bson.BsonDocumentWrapper; 7 | import org.bson.codecs.configuration.CodecRegistry; 8 | import org.bson.conversions.Bson; 9 | 10 | public class SyncUserSession implements Bson{ 11 | 12 | private String sessionId; 13 | private String userid; 14 | private String clientIPAddress; 15 | private String clientHostName; 16 | private String clientAgent; 17 | private Date loginTime; 18 | public enum SessionAttributes{ 19 | _id,userid,clientIPAddress,clientHostName,clientAgent,loginTime; 20 | } 21 | public String getSessionId() { 22 | return sessionId; 23 | } 24 | public void setSessionId(String sessionId) { 25 | this.sessionId = sessionId; 26 | } 27 | public String getUserid() { 28 | return userid; 29 | } 30 | public Date getLoginTime() { 31 | return loginTime; 32 | } 33 | public void setLoginTime(Date loginTime) { 34 | this.loginTime = loginTime; 35 | } 36 | public void setUserid(String userid) { 37 | this.userid = userid; 38 | } 39 | public String getClientIPAddress() { 40 | return clientIPAddress; 41 | } 42 | public void setClientIPAddress(String clientIPAddress) { 43 | this.clientIPAddress = clientIPAddress; 44 | } 45 | public String getClientHostName() { 46 | return clientHostName; 47 | } 48 | public void setClientHostName(String clientHostName) { 49 | this.clientHostName = clientHostName; 50 | } 51 | public String getClientAgent() { 52 | return clientAgent; 53 | } 54 | public void setClientAgent(String clientAgent) { 55 | this.clientAgent = clientAgent; 56 | } 57 | @Override 58 | public BsonDocument toBsonDocument(Class arg0, 59 | CodecRegistry codecRegistry) { 60 | return new BsonDocumentWrapper(this, 61 | codecRegistry.get(SyncUserSession.class)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/entities/UserActivity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.cisco.app.dbmigrator.migratorapp.logging.entities; 5 | 6 | /** 7 | * @author pnilayam 8 | * 9 | */ 10 | public class UserActivity { 11 | private String userId; 12 | private String sourceDbName; 13 | private String sourceSchemaName; 14 | private String targetDbName; 15 | private String targetSchemaName; 16 | 17 | public String getUserId() { 18 | return userId; 19 | } 20 | public void setUserId(String userId) { 21 | this.userId = userId; 22 | } 23 | public String getSourceDbName() { 24 | return sourceDbName; 25 | } 26 | public void setSourceDbName(String sourceDbName) { 27 | this.sourceDbName = sourceDbName; 28 | } 29 | public String getSourceSchemaName() { 30 | return sourceSchemaName; 31 | } 32 | public void setSourceSchemaName(String sourceSchemaName) { 33 | this.sourceSchemaName = sourceSchemaName; 34 | } 35 | public String getTargetDbName() { 36 | return targetDbName; 37 | } 38 | public void setTargetDbName(String targetDbName) { 39 | this.targetDbName = targetDbName; 40 | } 41 | public String getTargetSchemaName() { 42 | return targetSchemaName; 43 | } 44 | public void setTargetSchemaName(String targetSchemaName) { 45 | this.targetSchemaName = targetSchemaName; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/logging/entity/SyncNodeDetails.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.logging.entity; 2 | 3 | import java.util.List; 4 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncEvent; 5 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncNode; 6 | 7 | @SuppressWarnings("rawtypes") 8 | public class SyncNodeDetails { 9 | private SyncNode node; 10 | private List event; 11 | 12 | public SyncNode getNode() { 13 | return node; 14 | } 15 | public void setNode(SyncNode node) { 16 | this.node = node; 17 | } 18 | public List getEvent() { 19 | return event; 20 | } 21 | public void setEvent(List event) { 22 | this.event = event; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/service/AdminService.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.service; 2 | 3 | import java.util.List; 4 | 5 | import org.bson.types.ObjectId; 6 | 7 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncConnectionInfo; 8 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncUser; 9 | import com.cisco.app.dbmigrator.migratorapp.logging.entity.SyncNodeDetails; 10 | 11 | public interface AdminService { 12 | 13 | public List getNodeDetails(); 14 | 15 | public void saveUserDetails(String jsonStr); 16 | 17 | public void saveconnectionInfo(String jsonStr); 18 | 19 | public List getconnectionDetails(); 20 | 21 | public void deleteUser(String userId); 22 | 23 | public void deleteConnection(ObjectId id); 24 | 25 | public void encryptPass() throws Exception; 26 | 27 | public SyncConnectionInfo searchconnection(String dbName,String userName,String dbType); 28 | 29 | public SyncUser getUser(String userId); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/service/CollectionsDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.service; 2 | 3 | import java.util.List; 4 | 5 | import com.cisco.app.dbmigrator.migratorapp.core.meta.mongo.MongoObject; 6 | 7 | public interface CollectionsDetailsService { 8 | 9 | public List getAllCollections(String sourceDbName, String sourceSchemaName); 10 | 11 | public List getAttributesForCollection(String sourceDbName, String sourceSchemaName, String collectionName); 12 | 13 | public MongoObject processCollection(String sourceDbName, String sourceSchemaName, String collectionName); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/service/DatabaseDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.UserActivity; 7 | 8 | public interface DatabaseDetailsService { 9 | 10 | public Map fetchTablesDetails(UserActivity userActivity,String pattern); 11 | public Map fetchColumnsDetails(UserActivity userActivity,String tableName); 12 | public List getMatchedSequences(UserActivity userActivity,String seqPattern); 13 | public Map fetchColumnsForMultipleTables(String sourceDatabaseName,String sourceDatabaseSchema,List tableNameList); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/service/SyncEventService.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.service; 2 | 3 | import java.util.List; 4 | 5 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncError; 6 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncEvent; 7 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncMarker; 8 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.O2MSyncEventLog; 9 | 10 | /** 11 | * Service Interface with all behaviors for SyncEvent 12 | * 13 | * @author pnilayam 14 | * 15 | */ 16 | @SuppressWarnings("rawtypes") 17 | public interface SyncEventService { 18 | /** 19 | * Method to delete Event from System based on given eventId 20 | * 21 | * @param eventId 22 | */ 23 | public void deleteEvent(String eventId); 24 | 25 | /** 26 | * Method to fetch list of Events for input user Id 27 | * 28 | * @param userId 29 | * @return List of SyncEvent, null in case of no event found 30 | */ 31 | public List getEventsForUser(String userId); 32 | 33 | /** 34 | * Method to get Current status of SyncEvent 35 | * @param eventId 36 | * @return SyncMarker 37 | */ 38 | public SyncMarker getEventStatus(String eventId); 39 | 40 | /** 41 | * Method to get all errors for input eventId 42 | * @param eventId 43 | * @return 44 | */ 45 | public List getEventErrors(String eventId); 46 | 47 | /** 48 | * Method to Save SyncEvent into System from input eventJson 49 | * @param mappingJsonStr 50 | * @return 51 | */ 52 | public SyncEvent saveEvent(String eventJson); 53 | 54 | public SyncEvent retryEvent(String eventId,boolean retryFailed,boolean retryEntire,boolean dropCollection); 55 | 56 | public SyncEvent cancelEvents(String eventId); 57 | 58 | public void logEvent(O2MSyncEventLog eventInfo); 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/service/SyncEventServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.service; 2 | 3 | import java.util.List; 4 | 5 | import org.bson.types.ObjectId; 6 | 7 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncError; 8 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncEvent; 9 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncMarker; 10 | import com.cisco.app.dbmigrator.migratorapp.logging.codecs.SyncMapAndEventDecoder; 11 | import com.cisco.app.dbmigrator.migratorapp.logging.dao.O2MEventLogDao; 12 | import com.cisco.app.dbmigrator.migratorapp.logging.dao.SyncEventDao; 13 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.O2MSyncEventLog; 14 | 15 | @SuppressWarnings("rawtypes") 16 | public class SyncEventServiceImpl implements SyncEventService { 17 | private SyncEventDao eventDao; 18 | private SyncMapAndEventDecoder decoder; 19 | private O2MEventLogDao eventLogDao; 20 | public SyncEventDao getEventDao() { 21 | return eventDao; 22 | } 23 | 24 | public void setEventDao(SyncEventDao eventDao) { 25 | this.eventDao = eventDao; 26 | } 27 | 28 | public SyncMapAndEventDecoder getDecoder() { 29 | return decoder; 30 | } 31 | 32 | public void setDecoder(SyncMapAndEventDecoder decoder) { 33 | this.decoder = decoder; 34 | } 35 | 36 | @Override 37 | public void deleteEvent(String eventId) { 38 | eventDao.deleteEvent(new ObjectId(eventId)); 39 | } 40 | 41 | @Override 42 | public SyncMarker getEventStatus(String eventId) { 43 | if(eventId!=null && !eventId.isEmpty()){ 44 | return eventDao.getEventStats(new ObjectId(eventId)); 45 | } 46 | return null; 47 | } 48 | 49 | @Override 50 | public List getEventErrors(String eventId) { 51 | if(eventId!=null && !eventId.isEmpty()){ 52 | return eventDao.getEventErrors(new ObjectId(eventId)); 53 | } 54 | return null; 55 | } 56 | 57 | @Override 58 | public SyncEvent saveEvent(String mappingJsonStr) { 59 | SyncEvent event = decoder.decodeSyncEvent(mappingJsonStr); 60 | return eventDao.saveEvent(event); 61 | } 62 | 63 | @Override 64 | public List getEventsForUser(String userId) { 65 | return eventDao.getAllEventsForUser(userId); 66 | } 67 | 68 | @Override 69 | public SyncEvent retryEvent(String eventId,boolean retryFailed,boolean retryEntire,boolean dropCollection) { 70 | return eventDao.retryEvent(new ObjectId(eventId),retryFailed,retryEntire,dropCollection); 71 | } 72 | 73 | @Override 74 | public SyncEvent cancelEvents(String eventId) { 75 | return eventDao.cancelEvent(new ObjectId(eventId)); 76 | } 77 | 78 | @Override 79 | public void logEvent(O2MSyncEventLog eventInfo) { 80 | eventLogDao.logEvent(eventInfo); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/service/SyncMapService.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.service; 2 | 3 | import java.util.List; 4 | 5 | import com.cisco.app.dbmigrator.migratorapp.core.map.MongoToOracleMap; 6 | import com.cisco.app.dbmigrator.migratorapp.core.map.SyncMap; 7 | 8 | public interface SyncMapService { 9 | public void saveMappings(String jsonString); 10 | 11 | public SyncMap loadMapping(String mappingId); 12 | 13 | public List getAllMappings(); 14 | 15 | public String getMappingTables(String mappingId); 16 | 17 | public void deleteMapping(String mappingId); 18 | 19 | public List getMappingByMapType(String mapType); 20 | 21 | public MongoToOracleMap translateMap(String mappingId); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/service/SyncNodeDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.service; 2 | 3 | import java.util.List; 4 | import com.cisco.app.dbmigrator.migratorapp.logging.entity.SyncNodeDetails; 5 | 6 | public interface SyncNodeDetailsService { 7 | 8 | public List getNodeDetails(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/service/SyncNodeDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.service; 2 | 3 | import java.util.List; 4 | 5 | import com.cisco.app.dbmigrator.migratorapp.config.SyncConfig; 6 | import com.cisco.app.dbmigrator.migratorapp.constants.SyncConstants; 7 | import com.cisco.app.dbmigrator.migratorapp.logging.dao.SyncNodeDetailsDao; 8 | import com.cisco.app.dbmigrator.migratorapp.logging.entity.SyncNodeDetails; 9 | 10 | public class SyncNodeDetailsServiceImpl implements SyncNodeDetailsService{ 11 | private SyncNodeDetailsDao syncNodeDetailsDao = null; 12 | 13 | 14 | public SyncNodeDetailsDao getSyncNodeDetailsDao() { 15 | return syncNodeDetailsDao; 16 | } 17 | 18 | public void setSyncNodeDetailsDao(SyncNodeDetailsDao syncNodeDetailsDao) { 19 | this.syncNodeDetailsDao = syncNodeDetailsDao; 20 | } 21 | 22 | @Override 23 | public List getNodeDetails() { 24 | return syncNodeDetailsDao.getNodeDetails(getLifeCycle()); 25 | } 26 | 27 | private String getLifeCycle() { 28 | return SyncConfig.INSTANCE.getDbProperty(SyncConstants.LIFE)!=null?SyncConfig.INSTANCE.getDbProperty(SyncConstants.LIFE):"dev"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/BigDecimalLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | import java.math.BigDecimal; 4 | 5 | public class BigDecimalLiteral implements Literal { 6 | BigDecimal value; 7 | @Override 8 | public BigDecimal getSqlExpressionForMatchable() { 9 | return value; 10 | } 11 | 12 | @Override 13 | public Literal setLiteralValue(BigDecimal value) { 14 | this.value=value; 15 | return this; 16 | } 17 | 18 | @Override 19 | public String getLiteralType() { 20 | return SqlColumnType.NUMBER; 21 | } 22 | 23 | @Override 24 | public BigDecimal getLiteralValue() { 25 | return value; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/BlobLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | import java.sql.Blob; 4 | 5 | public class BlobLiteral implements Literal { 6 | 7 | private Blob value; 8 | 9 | public BlobLiteral() {} 10 | 11 | @Override 12 | public String getLiteralType() { 13 | return SqlColumnType.BLOB; 14 | } 15 | 16 | @Override 17 | public Blob getSqlExpressionForMatchable() { 18 | return value; 19 | } 20 | 21 | @Override 22 | public Literal setLiteralValue(Blob value) { 23 | this.value=value; 24 | return this; 25 | } 26 | 27 | @Override 28 | public Blob getLiteralValue() { 29 | return value; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/ClobLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | import java.sql.Clob; 4 | 5 | public class ClobLiteral implements Literal { 6 | 7 | private Clob value; 8 | 9 | public ClobLiteral() {} 10 | 11 | @Override 12 | public Clob getSqlExpressionForMatchable() { 13 | return value; 14 | } 15 | 16 | @Override 17 | public Literal setLiteralValue(Clob value) { 18 | this.value=value; 19 | return this; 20 | } 21 | 22 | @Override 23 | public String getLiteralType() { 24 | return SqlColumnType.CLOB; 25 | } 26 | 27 | @Override 28 | public Clob getLiteralValue() { 29 | return value; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/DateLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | import java.util.Date; 4 | 5 | public class DateLiteral implements Literal{ 6 | private Date date; 7 | @Override 8 | public java.sql.Date getSqlExpressionForMatchable() { 9 | return new java.sql.Date(date.getTime());//==null?null:date.toString(); 10 | } 11 | 12 | @Override 13 | public Literal setLiteralValue(Date value) { 14 | this.date=value; 15 | return this; 16 | } 17 | 18 | @Override 19 | public String getLiteralType() { 20 | return "DATE"; 21 | } 22 | 23 | @Override 24 | public java.sql.Date getLiteralValue() { 25 | return new java.sql.Date(date.getTime()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/JoinType.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | /** 4 | * @author pnilayam 5 | * 6 | */ 7 | public enum JoinType { 8 | INNER("JOIN"), LEFT_OUTER("LEFT OUTER JOIN"), RIGHT_OUTER("RIGHT OUTER JOIN"), FULL_OUTER("FULL OUTER JOIN"); 9 | String joinExpression; 10 | 11 | private JoinType(String joinExpression) { 12 | this.joinExpression = joinExpression; 13 | } 14 | 15 | public String getJoinExpression(){ 16 | return joinExpression; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/JoinedTable.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents.SQLFilters; 4 | 5 | /** 6 | * @author pnilayam 7 | * 8 | */ 9 | public class JoinedTable { 10 | @Override 11 | public String toString() { 12 | return "JoinedTable [table=" + table + ", joinType=" + joinType + ", filters=" + filters + "]"; 13 | } 14 | private OracleTable table; 15 | private JoinType joinType; 16 | private SQLFilters filters; 17 | 18 | public JoinedTable(OracleTable table, JoinType joinType, SQLFilters filters) { 19 | super(); 20 | this.table = table; 21 | this.joinType = joinType; 22 | this.filters = filters; 23 | } 24 | public JoinedTable(){} 25 | public SQLFilters getFilters() { 26 | return filters; 27 | } 28 | public void setFilters(SQLFilters filters) { 29 | this.filters = filters; 30 | } 31 | public OracleTable getTable() { 32 | return table; 33 | } 34 | public void setTable(OracleTable table) { 35 | this.table = table; 36 | } 37 | public JoinType getJoinType() { 38 | return joinType; 39 | } 40 | public void setJoinType(JoinType joinType) { 41 | this.joinType = joinType; 42 | } 43 | /* This is capable of one level join only as of now. need to write recursive logic to implement nth level of join*/ 44 | public StringBuilder getJoinedExpression(){ 45 | StringBuilder builder = new StringBuilder(); 46 | builder.append(QueryConstants.SPACE) 47 | .append(joinType.getJoinExpression()) 48 | .append(QueryConstants.SPACE) 49 | .append(table.getTableName()) 50 | .append(QueryConstants.SPACE) 51 | .append(table.getTableAlias()) 52 | .append(QueryConstants.NEXT_LINE) 53 | .append(QueryConstants.INDENT) 54 | .append(QueryConstants.INDENT) 55 | .append(QueryConstants.ON) 56 | .append(QueryConstants.SPACE) 57 | .append(QueryConstants.OPEN_PARANTHESIS) 58 | .append(filters.getFilterExpression()) 59 | .append(QueryConstants.CLOSE_PARANTHESIS); 60 | return builder; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/Literal.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | public interface Literal extends MatchAble { 4 | public Literal setLiteralValue(T value); 5 | public String getLiteralType(); 6 | public T getLiteralValue(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/LogicalOperator.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | /** 4 | * Enum representing all logical operators
5 | * Available operators : 6 | *
i) AND
7 | *
ii) OR
8 | *
iii) NOT
9 | *
10 | * @author pnilayam 11 | * 12 | */ 13 | public enum LogicalOperator{ 14 | AND("AND"),OR("OR"),NOT("NOT"); 15 | private String expression; 16 | private LogicalOperator(String expression){ 17 | this.expression=expression; 18 | } 19 | public String getExpression(){ 20 | return expression; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/MatchAble.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | public interface MatchAble{ 4 | public T getSqlExpressionForMatchable(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/MatchOperator.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | /** 4 | * Enum representing all Match operators
5 | * Available operators : 6 | *
EQ("=")
7 | * NE("!=")
8 | * GT(">")
9 | * GTE(">=")
10 | * LT("<")
11 | * LTE("<=")
12 | * LIKE("LIKE")
13 | * EXISTS("EXISTS")
14 | * IS_NULL("IS NULL")
15 | * IS_NOT_NULL("IS NOT NULL")
16 | * BETWEEN("BETWEEN") 17 | *
18 | * 19 | * @author pnilayam 20 | * 21 | */ 22 | public enum MatchOperator{ 23 | EQ("="),NE("!="),GT(">"),GTE(">="),LT("<"),LTE("<="),LIKE("LIKE"),EXISTS("EXISTS"),IS_NULL("IS NULL"),IS_NOT_NULL("IS NOT NULL"),BETWEEN("BETWEEN"); 24 | private String expression; 25 | private MatchOperator(String expression){ 26 | this.expression=expression; 27 | } 28 | public String getExpression(){ 29 | return expression; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/MatchWithColumn.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | /** 4 | * @author pnilayam 5 | * 6 | */ 7 | public class MatchWithColumn { 8 | private MatchWithColumn() { 9 | } 10 | 11 | /** 12 | * @param tableAlias 13 | * @param columnName 14 | * @return 15 | */ 16 | public static OracleColumn column(String tableAlias, String columnName) { 17 | OracleColumn column = new OracleColumn(); 18 | column.setColumnName(columnName); 19 | column.setTableAlias(tableAlias); 20 | column.setColumnAlias(tableAlias+"_"+columnName); 21 | column.setParentColumn(false); 22 | return column; 23 | } 24 | /** 25 | * @param tableAlias 26 | * @param columnName 27 | * @param isParentColumn 28 | * @return 29 | */ 30 | public static OracleColumn column(String tableAlias, String columnName ,boolean isParentColumn) { 31 | OracleColumn column = new OracleColumn(); 32 | column.setColumnName(columnName); 33 | column.setTableAlias(tableAlias); 34 | column.setColumnAlias(tableAlias+"_"+columnName); 35 | column.setParentColumn(isParentColumn); 36 | return column; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/NullLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | @SuppressWarnings("rawtypes") 4 | public class NullLiteral implements Literal{ 5 | 6 | @Override 7 | public Object getSqlExpressionForMatchable() { 8 | return null; 9 | } 10 | 11 | @Override 12 | public Literal setLiteralValue(Object value) { 13 | return this; 14 | } 15 | 16 | @Override 17 | public String getLiteralType() { 18 | return "NULL"; 19 | } 20 | 21 | @Override 22 | public Object getLiteralValue() { 23 | return null; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/NumberLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | public class NumberLiteral implements Literal { 4 | private double value; 5 | 6 | public NumberLiteral(){} 7 | 8 | public static NumberLiteral setNumber(int value){ 9 | NumberLiteral number = new NumberLiteral(); 10 | number.value=value; 11 | return number; 12 | } 13 | public static NumberLiteral setNumber(double value){ 14 | NumberLiteral number = new NumberLiteral(); 15 | number.value=value; 16 | return number; 17 | } 18 | 19 | @Override 20 | public Literal setLiteralValue(Double value) { 21 | this.value = value; 22 | return this; 23 | } 24 | 25 | @Override 26 | public String getLiteralType() { 27 | return "NUMBER"; 28 | } 29 | 30 | @Override 31 | public Double getLiteralValue() { 32 | return value; 33 | } 34 | 35 | @Override 36 | public Double getSqlExpressionForMatchable() { 37 | return value; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/OracleEntity.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | public interface OracleEntity{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/OracleTimeStampLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | import java.sql.Timestamp; 4 | import java.util.Calendar; 5 | import java.util.Date; 6 | import java.util.TimeZone; 7 | 8 | import oracle.sql.TIMESTAMP; 9 | 10 | public class OracleTimeStampLiteral implements Literal { 11 | TIMESTAMP ts ; 12 | @Override 13 | public TIMESTAMP getSqlExpressionForMatchable() { 14 | return ts; 15 | } 16 | 17 | @Override 18 | public Literal setLiteralValue(TIMESTAMP value) { 19 | ts=value; 20 | return null; 21 | } 22 | 23 | public Literal setLiteralValue(Date value) { 24 | ts = new TIMESTAMP(new Timestamp(value.getTime()), Calendar.getInstance(TimeZone.getTimeZone("PST"))); 25 | return this; 26 | } 27 | 28 | @Override 29 | public String getLiteralType() { 30 | return SqlColumnType.TIMESTAMP; 31 | } 32 | 33 | @Override 34 | public TIMESTAMP getLiteralValue() { 35 | return ts; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/QueryConstants.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | public enum QueryConstants { 4 | QueryConst; 5 | public static final String QUOTE = "'"; 6 | public static final String INDENT = " "; 7 | public static final String SPACE = " "; 8 | public static final String COMMA = ","; 9 | public static final String DOT = "."; 10 | public static final String NEXT_LINE = "\n"; 11 | public static final String OPEN_PARANTHESIS = "("; 12 | public static final String CLOSE_PARANTHESIS = ")"; 13 | public static final String ON = "ON"; 14 | public static final String BIND_MARKER = "?"; 15 | public static final String COLON = ":"; 16 | public static final String NEXTVAL = ".NEXTVAL"; 17 | public static final String EQUALS = "="; 18 | public static final String WHERE = "WHERE"; 19 | public static final String NVL = "NVL"; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/RowIdLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | import oracle.sql.ROWID; 4 | 5 | public class RowIdLiteral implements Literal { 6 | ROWID value; 7 | @Override 8 | public ROWID getSqlExpressionForMatchable() { 9 | return value; 10 | } 11 | 12 | @Override 13 | public Literal setLiteralValue(ROWID value) { 14 | this.value=value; 15 | return this; 16 | } 17 | 18 | public Literal setLiteralValue(String value) { 19 | return setLiteralValue(value.getBytes()); 20 | } 21 | 22 | public Literal setLiteralValue(byte [] value) { 23 | ROWID rowId = new ROWID(value); 24 | this.value=rowId; 25 | return this; 26 | } 27 | 28 | @Override 29 | public String getLiteralType() { 30 | return SqlColumnType.ROWID; 31 | } 32 | 33 | @Override 34 | public ROWID getLiteralValue() { 35 | return value; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/Selectable.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | public interface Selectable { 4 | // public void generateSelectQuery(); 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/SortByColumn.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | /** 4 | * @author pnilayam 5 | * 6 | */ 7 | public class SortByColumn { 8 | private String columnAlias; 9 | private SortOrder sortOrder; 10 | 11 | private SortByColumn() { 12 | } 13 | 14 | /** 15 | * @param tableAlias 16 | * @param columnName 17 | * @param sortOrder 18 | * @return 19 | */ 20 | public static SortByColumn column(String tableAlias, String columnName, SortOrder sortOrder) { 21 | SortByColumn column = new SortByColumn(); 22 | column.columnAlias = tableAlias + QueryConstants.DOT + columnName; 23 | column.sortOrder = sortOrder; 24 | return column; 25 | } 26 | 27 | /** 28 | * @param tableAlias 29 | * @param columnName 30 | * @return 31 | */ 32 | public static SortByColumn column(String tableAlias, String columnName) { 33 | SortByColumn column = new SortByColumn(); 34 | column.columnAlias = tableAlias + QueryConstants.DOT + columnName; 35 | column.sortOrder = SortOrder.ASCENDING; 36 | return column; 37 | } 38 | 39 | /** 40 | * @param columnAlias 41 | * @param sortOrder 42 | * @return 43 | */ 44 | public static SortByColumn column(String columnAlias, SortOrder sortOrder) { 45 | SortByColumn column = new SortByColumn(); 46 | column.columnAlias = columnAlias; 47 | column.sortOrder = sortOrder; 48 | return column; 49 | } 50 | 51 | /** 52 | * @param columnAlias 53 | * @return 54 | */ 55 | public static SortByColumn column(String columnAlias) { 56 | SortByColumn column = new SortByColumn(); 57 | column.columnAlias = columnAlias; 58 | column.sortOrder = SortOrder.ASCENDING; 59 | return column; 60 | } 61 | 62 | @Override 63 | public int hashCode() { 64 | final int prime = 31; 65 | int result = 1; 66 | result = prime * result + ((columnAlias == null) ? 0 : columnAlias.hashCode()); 67 | return result; 68 | } 69 | 70 | @Override 71 | public boolean equals(Object obj) { 72 | if (this == obj) 73 | return true; 74 | if (obj == null) 75 | return false; 76 | if (getClass() != obj.getClass()) 77 | return false; 78 | SortByColumn other = (SortByColumn) obj; 79 | if (columnAlias == null) { 80 | if (other.columnAlias != null) 81 | return false; 82 | } else if (!columnAlias.equals(other.columnAlias)) 83 | return false; 84 | return true; 85 | } 86 | 87 | @Override 88 | public String toString() { 89 | StringBuilder builder = new StringBuilder(); 90 | builder.append(columnAlias).append(QueryConstants.SPACE).append(sortOrder.sortOrder()) 91 | .append(QueryConstants.COMMA); 92 | return builder.toString(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/SortOrder.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | public enum SortOrder { 4 | ASCENDING("ASC"), DESCECNDING("DESC"); 5 | String sortOrder; 6 | 7 | private SortOrder(String sortOrder) { 8 | this.sortOrder = sortOrder; 9 | } 10 | 11 | public String sortOrder() { 12 | return sortOrder; 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/SqlColumnType.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | public enum SqlColumnType { 4 | SqlColumnType; 5 | public static final String VARCHAR2 = "VARCHAR2"; 6 | public static final String NUMBER = "NUMBER"; 7 | public static final String DATE = "DATE"; 8 | public static final String TIMESTAMP = "TIMESTAMP"; 9 | public static final String BLOB = "BLOB"; 10 | public static final String CLOB = "CLOB"; 11 | public static final String ARRAY = "ARRAY"; 12 | public static final String ROWID = "ROWID"; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/SqlLiteralFactory.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | import java.math.BigDecimal; 4 | import java.math.MathContext; 5 | import java.sql.Blob; 6 | import java.sql.Clob; 7 | import java.sql.Connection; 8 | import java.sql.SQLException; 9 | import java.sql.Timestamp; 10 | import java.text.ParseException; 11 | import java.text.SimpleDateFormat; 12 | import java.util.Calendar; 13 | import java.util.Date; 14 | import java.util.TimeZone; 15 | 16 | import org.bson.types.Binary; 17 | 18 | import com.cisco.app.dbmigrator.migratorapp.constants.SyncConstants; 19 | 20 | import oracle.sql.ROWID; 21 | import oracle.sql.TIMESTAMP; 22 | 23 | @SuppressWarnings({ "rawtypes", "unchecked" }) 24 | public class SqlLiteralFactory { 25 | private SqlLiteralFactory(){} 26 | public static Literal getLiteral(Object value, String dataType) { 27 | Literal literal = null; 28 | if (value == null || SyncConstants.EMPTY_STRING.equalsIgnoreCase(String.valueOf(value))) { 29 | literal = new NullLiteral(); 30 | 31 | } else { 32 | if (SqlColumnType.VARCHAR2.equalsIgnoreCase(dataType)) { 33 | literal = new VarcharLiteral(); 34 | value = String.valueOf(value); 35 | } else if (SqlColumnType.NUMBER.equalsIgnoreCase(dataType)) { 36 | literal = new BigDecimalLiteral(); 37 | value = new BigDecimal(String.valueOf(value),MathContext.DECIMAL128); 38 | } else if (SqlColumnType.DATE.equalsIgnoreCase(dataType) || SqlColumnType.TIMESTAMP.equals(dataType)) { 39 | literal = new OracleTimeStampLiteral(); 40 | try { 41 | if (value instanceof String) { 42 | value = new SimpleDateFormat("yyyy-MM-dd").parse(String.valueOf(value)); 43 | } 44 | Date dateVal = (Date) value; 45 | value = new TIMESTAMP(new Timestamp(dateVal.getTime()), Calendar.getInstance(TimeZone.getTimeZone("PST"))); 46 | } catch (ParseException e) { 47 | e.printStackTrace(); 48 | } 49 | } else if (SqlColumnType.ROWID.equalsIgnoreCase(dataType)){ 50 | if(value instanceof String){ 51 | value = new ROWID(String.valueOf(value).getBytes()); 52 | } 53 | literal = new RowIdLiteral(); 54 | } 55 | else { 56 | literal = new VarcharLiteral(); 57 | value = String.valueOf(value); 58 | } 59 | literal.setLiteralValue(value); 60 | } 61 | return literal; 62 | } 63 | 64 | public static Literal getLobLiteral(Object inputValue, String dataType, Connection connection) throws SQLException{ 65 | Literal literal = null; 66 | if(connection==null){ 67 | literal = new NullLiteral(); 68 | }else{ 69 | if(SqlColumnType.BLOB.equalsIgnoreCase(dataType)){ 70 | literal= new BlobLiteral(); 71 | Blob blob = connection.createBlob(); 72 | Binary objArray = (Binary) inputValue; 73 | blob.setBytes(1, objArray.getData()); 74 | literal.setLiteralValue(blob); 75 | }else if(SqlColumnType.CLOB.equalsIgnoreCase(dataType)){ 76 | literal = new ClobLiteral(); 77 | Clob clob = connection.createClob(); 78 | clob.setString(1, String.valueOf(inputValue)); 79 | literal.setLiteralValue(clob); 80 | } 81 | } 82 | return literal; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/TimeStampLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | import java.sql.Timestamp; 4 | import java.util.Date; 5 | 6 | public class TimeStampLiteral implements Literal { 7 | private Timestamp timestamp; 8 | @Override 9 | public Timestamp getSqlExpressionForMatchable() { 10 | return timestamp; 11 | } 12 | 13 | @Override 14 | public Literal setLiteralValue(Date value) { 15 | timestamp = new Timestamp(value.getTime()); 16 | return this; 17 | } 18 | 19 | @Override 20 | public String getLiteralType() { 21 | return "TIMESTAMP"; 22 | } 23 | 24 | @Override 25 | public Timestamp getLiteralValue() { 26 | return timestamp; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/entities/VarcharLiteral.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities; 2 | 3 | public class VarcharLiteral implements Literal { 4 | private String value; 5 | 6 | public VarcharLiteral(){} 7 | 8 | public static VarcharLiteral setVarchar(String value){ 9 | VarcharLiteral literal = new VarcharLiteral(); 10 | literal.value=value; 11 | return literal; 12 | } 13 | @Override 14 | public int hashCode() { 15 | final int prime = 31; 16 | int result = 1; 17 | result = prime * result + ((value == null) ? 0 : value.hashCode()); 18 | return result; 19 | } 20 | @Override 21 | public boolean equals(Object obj) { 22 | if (this == obj) 23 | return true; 24 | if (obj == null) 25 | return false; 26 | if (getClass() != obj.getClass()) 27 | return false; 28 | VarcharLiteral other = (VarcharLiteral) obj; 29 | if (value == null) { 30 | if (other.value != null) 31 | return false; 32 | } else if (!value.equals(other.value)) 33 | return false; 34 | return true; 35 | } 36 | @Override 37 | public String toString() { 38 | return "VarcharLiteral [value=" + value + "]"; 39 | } 40 | //@Override 41 | public Literal setLiteralValue(String value) { 42 | this.value = value; 43 | return this; 44 | } 45 | 46 | @Override 47 | public String getLiteralType() { 48 | return "VARCHAR2"; 49 | } 50 | 51 | @Override 52 | public String getLiteralValue() { 53 | return value; 54 | } 55 | 56 | @Override 57 | public String getSqlExpressionForMatchable() { 58 | return value; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/queries/DeleteQueryBuilder.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.queries; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleColumn; 7 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.QueryConstants; 8 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents.SQLFilters; 9 | 10 | public class DeleteQueryBuilder implements QueryBuilder { 11 | private static final String DELETE_FROM = "DELETE FROM "; 12 | String FROM = "FROM"; 13 | 14 | private DeleteQueryComponents queryComponents; 15 | 16 | public DeleteQueryBuilder() { 17 | this.queryComponents = new DeleteQueryComponents(); 18 | } 19 | 20 | public FromTable delete() { 21 | return new FromTable(); 22 | } 23 | 24 | public final class FromTable { 25 | private FromTable() { 26 | } 27 | 28 | public AddFilter from(String tableName, String tableAlias) { 29 | fromTable(tableName, tableAlias); 30 | return new AddFilter(); 31 | } 32 | } 33 | 34 | public final class AddFilter { 35 | private AddFilter() { 36 | } 37 | 38 | public GetQuery where(SQLFilters filters) { 39 | whereCondition(filters); 40 | return new GetQuery(); 41 | } 42 | 43 | public String getQuery(Set columnAliasSet) { 44 | return buildQuery(columnAliasSet); 45 | } 46 | } 47 | 48 | public final class GetQuery { 49 | private GetQuery() { 50 | } 51 | 52 | public String getQuery(Set columnAliasSet) { 53 | return buildQuery(columnAliasSet); 54 | } 55 | } 56 | 57 | private void fromTable(String tableName, String tableAlias) { 58 | queryComponents.setTableName(tableName); 59 | queryComponents.setTableAlias(tableAlias); 60 | } 61 | 62 | private void whereCondition(SQLFilters filters) { 63 | queryComponents.setFilter(filters); 64 | } 65 | 66 | private String buildQuery(Set columnAliasSet) { 67 | StringBuilder builder = new StringBuilder(DELETE_FROM); 68 | builder.append(queryComponents.getTableName()).append(QueryConstants.SPACE) 69 | .append(queryComponents.getTableAlias()).append(QueryConstants.NEXT_LINE).append(QueryConstants.INDENT) 70 | .append(QueryConstants.WHERE).append(QueryConstants.SPACE); 71 | 72 | Set keyColumns = new HashSet(); 73 | builder.append(queryComponents.getFilter().getMergeQueryExpression(keyColumns)); 74 | //TODO : need to revisit this 75 | for(OracleColumn column : keyColumns){ 76 | columnAliasSet.add(column.getColumnAlias()); 77 | } 78 | return builder.toString(); 79 | } 80 | 81 | private final class DeleteQueryComponents { 82 | private DeleteQueryComponents() { 83 | } 84 | 85 | private String tableName; 86 | private String tableAlias; 87 | 88 | public String getTableAlias() { 89 | return tableAlias; 90 | } 91 | 92 | public void setTableAlias(String tableAlias) { 93 | this.tableAlias = tableAlias; 94 | } 95 | 96 | private SQLFilters filter; 97 | 98 | public String getTableName() { 99 | return tableName; 100 | } 101 | 102 | public void setTableName(String tableName) { 103 | this.tableName = tableName; 104 | } 105 | 106 | public SQLFilters getFilter() { 107 | return filter; 108 | } 109 | 110 | public void setFilter(SQLFilters filter) { 111 | this.filter = filter; 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/queries/InsertQueryComponents.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.queries; 2 | 3 | import java.util.LinkedHashSet; 4 | import java.util.Map; 5 | import java.util.Set; 6 | 7 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleTable; 8 | 9 | public class InsertQueryComponents { 10 | private Set tables; 11 | private Map columnValues; 12 | public Set getTables() { 13 | return tables; 14 | } 15 | public void setTables(Set tables) { 16 | if(tables==null){ 17 | tables = new LinkedHashSet(); 18 | } 19 | this.tables = tables; 20 | } 21 | public Map getColumnValues() { 22 | return columnValues; 23 | } 24 | public void setColumnValues(Map columnValues) { 25 | this.columnValues = columnValues; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/queries/MergeQueryComponents.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.queries; 2 | 3 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleTable; 4 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents.SQLFilters; 5 | 6 | public class MergeQueryComponents { 7 | private OracleTable targetTable; 8 | private OracleTable sourceTable; 9 | private SQLFilters filters; 10 | public OracleTable getSourceTable() { 11 | return sourceTable; 12 | } 13 | public void setSourceTable(OracleTable sourceTable) { 14 | this.sourceTable = sourceTable; 15 | } 16 | public OracleTable getTargetTable() { 17 | return targetTable; 18 | } 19 | public void setTargetTable(OracleTable targetTable) { 20 | this.targetTable = targetTable; 21 | } 22 | public SQLFilters getFilters() { 23 | return filters; 24 | } 25 | public void setFilters(SQLFilters filters) { 26 | this.filters = filters; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/queries/QueryBuilder.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.queries; 2 | 3 | public interface QueryBuilder { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/queries/SelectQueryComponents.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.queries; 2 | 3 | import java.util.LinkedHashSet; 4 | 5 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleTable; 6 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.SortByColumn; 7 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents.SQLFilters; 8 | 9 | public class SelectQueryComponents { 10 | 11 | private LinkedHashSet referencedTables; 12 | private LinkedHashSet sortedColumns; 13 | private SQLFilters filter; 14 | 15 | public SQLFilters getFilter() { 16 | return filter; 17 | } 18 | 19 | public void setFilter(SQLFilters filter) { 20 | this.filter = filter; 21 | } 22 | 23 | public LinkedHashSet getSortedColumns() { 24 | return sortedColumns; 25 | } 26 | 27 | public void setSortedColumns(LinkedHashSet sortedColumns) { 28 | this.sortedColumns = sortedColumns; 29 | } 30 | 31 | public LinkedHashSet getReferencedTables() { 32 | return referencedTables; 33 | } 34 | 35 | public void setReferencedTables(LinkedHashSet referencedTables) { 36 | this.referencedTables = referencedTables; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/queries/UpdateQueryBuilder.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.queries; 2 | 3 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleColumn; 4 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleTable; 5 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.QueryConstants; 6 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents.SQLFilters; 7 | 8 | public class UpdateQueryBuilder { 9 | private static final String UPDATE = "UPDATE "; 10 | private static final String SET = "SET"; 11 | private final UpdateQueryComponents queryComponents; 12 | 13 | public UpdateQueryBuilder(){ 14 | super(); 15 | queryComponents = new UpdateQueryComponents(); 16 | } 17 | 18 | public AddTable update(){ 19 | return new AddTable(); 20 | } 21 | 22 | public final class AddTable{ 23 | public AddFilter table(OracleTable table){ 24 | addTable(table); 25 | return new AddFilter(); 26 | } 27 | private AddTable(){} 28 | } 29 | 30 | public final class AddFilter{ 31 | private AddFilter(){} 32 | public GetQuery addFilter(SQLFilters filter){ 33 | where(filter); 34 | return new GetQuery(); 35 | } 36 | public String getQuery(){ 37 | return buildQuery(); 38 | } 39 | } 40 | 41 | public final class GetQuery{ 42 | private GetQuery(){} 43 | public String getQuery(){ 44 | return buildQuery(); 45 | } 46 | } 47 | 48 | private void addTable(OracleTable table){ 49 | queryComponents.setTable(table); 50 | } 51 | private UpdateQueryBuilder where(SQLFilters filters){ 52 | queryComponents.setFilters(filters); 53 | return this; 54 | } 55 | private String buildQuery() { 56 | StringBuilder builder = new StringBuilder(UPDATE); 57 | OracleTable table = queryComponents.getTable(); 58 | builder.append(table.getTableName()).append(QueryConstants.NEXT_LINE).append(QueryConstants.INDENT).append(SET); 59 | for (OracleColumn column : table.getColumns()) { 60 | builder.append(column.getColumnName()).append(QueryConstants.SPACE).append(QueryConstants.EQUALS) 61 | .append(QueryConstants.SPACE).append(QueryConstants.COLON).append(column.getColumnAlias()) 62 | .append(QueryConstants.COMMA).append(QueryConstants.NEXT_LINE); 63 | } 64 | builder.deleteCharAt(builder.lastIndexOf(QueryConstants.COMMA)); 65 | if (queryComponents.getFilters() != null) { 66 | builder.append(QueryConstants.WHERE).append(QueryConstants.SPACE); 67 | builder.append(queryComponents.getFilters().getFilterExpression()); 68 | builder.append(QueryConstants.NEXT_LINE); 69 | } 70 | return builder.toString().trim(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/queries/UpdateQueryComponents.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.queries; 2 | 3 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleTable; 4 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents.SQLFilters; 5 | 6 | public class UpdateQueryComponents { 7 | private OracleTable table; 8 | private SQLFilters filters; 9 | public OracleTable getTable() { 10 | return table; 11 | } 12 | public void setTable(OracleTable table) { 13 | this.table = table; 14 | } 15 | public SQLFilters getFilters() { 16 | return filters; 17 | } 18 | public void setFilters(SQLFilters filters) { 19 | this.filters = filters; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/sqlcomponents/LogicalOperation.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.LogicalOperator; 7 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.MatchAble; 8 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.OracleColumn; 9 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.QueryConstants; 10 | 11 | /** 12 | * @author pnilayam 13 | * 14 | */ 15 | public abstract class LogicalOperation { 16 | 17 | private MatchOperation matchOperation; 18 | private SQLFilters subConditions; 19 | private LogicalOperator operator; 20 | public LogicalOperation(MatchOperation matchOperation,LogicalOperator operator) { 21 | super(); 22 | this.matchOperation = matchOperation; 23 | this.operator=operator; 24 | } 25 | public LogicalOperation(SQLFilters subConditions,LogicalOperator operator) { 26 | super(); 27 | this.subConditions = subConditions; 28 | this.operator=operator; 29 | } 30 | public MatchOperation getMatchOperation() { 31 | return matchOperation; 32 | } 33 | public LogicalOperator getOperator() { 34 | return operator; 35 | } 36 | public SQLFilters getOperation() { 37 | return subConditions; 38 | } 39 | /** 40 | * @return 41 | */ 42 | public String getLogicalExpression() { 43 | StringBuilder builder = new StringBuilder(); 44 | builder.append(QueryConstants.NEXT_LINE).append(QueryConstants.SPACE).append(getOperator().getExpression()).append(QueryConstants.SPACE); 45 | if(matchOperation!=null){ 46 | builder.append(matchOperation.getMatchExpression()); 47 | } 48 | else if(subConditions!=null){ 49 | builder.append(QueryConstants.OPEN_PARANTHESIS); 50 | builder.append(subConditions.getFilterExpression()); 51 | builder.append(QueryConstants.CLOSE_PARANTHESIS); 52 | } 53 | return builder.toString(); 54 | } 55 | /** 56 | * @param literals 57 | * @return 58 | */ 59 | @SuppressWarnings("rawtypes") 60 | public String getPositionedLogicalExpression(List literals) { 61 | StringBuilder builder = new StringBuilder(); 62 | builder.append(QueryConstants.NEXT_LINE).append(QueryConstants.SPACE).append(getOperator().getExpression()).append(QueryConstants.SPACE); 63 | if(matchOperation!=null){ 64 | builder.append(matchOperation.getPositionedExpression(literals)); 65 | } 66 | else if(subConditions!=null){ 67 | builder.append(QueryConstants.OPEN_PARANTHESIS); 68 | builder.append(subConditions.getPositionedExpression(literals)); 69 | builder.append(QueryConstants.CLOSE_PARANTHESIS); 70 | } 71 | return builder.toString(); 72 | } 73 | public String getMergeExpression(Set keyColumns) { 74 | StringBuilder builder = new StringBuilder(); 75 | builder.append(QueryConstants.NEXT_LINE).append(QueryConstants.SPACE).append(getOperator().getExpression()).append(QueryConstants.SPACE); 76 | if(matchOperation!=null){ 77 | builder.append(matchOperation.getMergeExpression(keyColumns)); 78 | } 79 | else if(subConditions!=null){ 80 | builder.append(QueryConstants.OPEN_PARANTHESIS); 81 | builder.append(subConditions.getMergeQueryExpression(keyColumns)); 82 | builder.append(QueryConstants.CLOSE_PARANTHESIS); 83 | } 84 | return builder.toString(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/sqlcomponents/OperationsFactory.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents; 2 | 3 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.MatchAble; 4 | @SuppressWarnings("rawtypes") 5 | public class OperationsFactory { 6 | 7 | public static MatchOperation getMatchExpression(MatchAble leftExpression, MatchAble rightExpression, 8 | String operationType) { 9 | 10 | if ("eq".equalsIgnoreCase(operationType)) { 11 | return Operations.eq(leftExpression, rightExpression); 12 | } else if ("gt".equalsIgnoreCase(operationType)) { 13 | return Operations.gt(leftExpression, rightExpression); 14 | } 15 | else if ("gte".equalsIgnoreCase(operationType)) { 16 | return Operations.gte(leftExpression, rightExpression); 17 | } 18 | else if ("lt".equalsIgnoreCase(operationType)) { 19 | return Operations.lt(leftExpression, rightExpression); 20 | } 21 | else if ("lte".equalsIgnoreCase(operationType)) { 22 | return Operations.lte(leftExpression, rightExpression); 23 | } 24 | else if ("ne".equalsIgnoreCase(operationType)) { 25 | return Operations.ne(leftExpression, rightExpression); 26 | } 27 | else if ("IS_NULL".equalsIgnoreCase(operationType)) { 28 | return Operations.isNull(leftExpression); 29 | } 30 | else if ("IS_NOT_NULL".equalsIgnoreCase(operationType)) { 31 | return Operations.isNotNull(leftExpression); 32 | } 33 | else if ("like".equalsIgnoreCase(operationType)) { 34 | return Operations.like(leftExpression, rightExpression); 35 | } 36 | else { 37 | return Operations.eq(leftExpression, rightExpression); 38 | } 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/sqlbuilder/sqlcomponents/SetOperation.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.sqlbuilder.sqlcomponents; 2 | 3 | public abstract class SetOperation { 4 | protected enum SetOperators{ 5 | UNION,UNIONALL,MINUS,INTERSECT; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/utilities/encrypt/EncryptorDecryptor.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.utilities.encrypt; 2 | 3 | import java.security.Key; 4 | 5 | import javax.crypto.Cipher; 6 | import javax.crypto.spec.SecretKeySpec; 7 | 8 | import ch.qos.logback.core.encoder.ByteArrayUtil; 9 | 10 | public final class EncryptorDecryptor { 11 | private static final String ALGORITHM = "AES"; 12 | private static final byte[] keyBytes = new byte[] { '$','^','9','(','U','8','!','1','8','!','@' ,'#','3','9','$','@'}; 13 | 14 | public static byte[] encrypt(String valueToEnc, String passPhrase) throws Exception { 15 | Key key = generateKey(passPhrase); 16 | Cipher c = Cipher.getInstance(ALGORITHM); 17 | c.init(Cipher.ENCRYPT_MODE, key); 18 | byte[] encValue = c.doFinal(valueToEnc.getBytes()); 19 | return encValue; 20 | } 21 | 22 | public static String encryptToString(String valueToEnc , String passPhrase) throws Exception { 23 | return ByteArrayUtil.toHexString(encrypt(valueToEnc, passPhrase)); 24 | } 25 | 26 | public static String decrypt(byte[] encryptedValue , String passPhrase) throws Exception { 27 | Key key = generateKey(passPhrase); 28 | Cipher c = Cipher.getInstance(ALGORITHM); 29 | c.init(Cipher.DECRYPT_MODE, key); 30 | byte[] decrypted = c.doFinal(encryptedValue); 31 | return new String(decrypted); 32 | } 33 | 34 | public static String decrypt(String encryptedPwd , String passPhrase) throws Exception { 35 | return decrypt(ByteArrayUtil.hexStringToByteArray(encryptedPwd), passPhrase); 36 | } 37 | 38 | private static Key generateKey(String passPhrase) throws Exception { 39 | Key key = new SecretKeySpec(getKeyBytes(passPhrase), ALGORITHM); 40 | return key; 41 | } 42 | 43 | private static byte[] getKeyBytes(String passPhrase) throws Exception{ 44 | if(passPhrase==null||passPhrase.isEmpty()){ 45 | return keyBytes; 46 | } 47 | if(passPhrase.length()==16){ 48 | return passPhrase.getBytes(); 49 | }else{ 50 | throw new Exception("Encryption key must be of 16 chars"); 51 | } 52 | } 53 | 54 | public static void main(String [] args) throws Exception{ 55 | String plainText = "ccwM1CDdevApp"; 56 | String hex = encryptToString(plainText , "#$Y9K39KRYP8K3Y#"); 57 | System.out.println(hex); 58 | String str = decrypt(hex , "#$Y9K39KRYP8K3Y#"); 59 | System.out.println(str); 60 | } 61 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/utilities/mongo/MongoDbUtilities.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.utilities.mongo; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.bson.conversions.Bson; 8 | import org.bson.types.ObjectId; 9 | 10 | import com.cisco.app.dbmigrator.migratorapp.core.event.SyncError; 11 | import com.cisco.app.dbmigrator.migratorapp.logging.connection.MongoConnection; 12 | import com.cisco.app.dbmigrator.migratorapp.logging.dao.SyncEventDao; 13 | import com.cisco.app.dbmigrator.migratorapp.logging.entities.SyncConnectionInfo; 14 | import com.cisco.app.dbmigrator.migratorapp.sqlbuilder.entities.MatchOperator; 15 | import com.mongodb.MongoClient; 16 | import com.mongodb.MongoClientOptions; 17 | import com.mongodb.MongoCredential; 18 | import com.mongodb.ReadPreference; 19 | import com.mongodb.ServerAddress; 20 | import com.mongodb.client.model.Filters; 21 | 22 | public final class MongoDbUtilities { 23 | private MongoDbUtilities(){} 24 | public List getAllCollections(){ 25 | List collectionList = new ArrayList(); 26 | return MongoConnection.INSTANCE.getMongoDataBase().listCollectionNames().into(collectionList); 27 | } 28 | 29 | public static Bson getFilterBson(MatchOperator operator , String attributeName , Object value){ 30 | Bson filter = null; 31 | switch(operator){ 32 | case GT : 33 | filter=Filters.gt(attributeName, value); 34 | break; 35 | case LT : 36 | filter=Filters.lt(attributeName, value); 37 | break; 38 | case GTE : 39 | filter=Filters.gte(attributeName, value); 40 | break; 41 | case LTE : 42 | filter=Filters.lte(attributeName, value); 43 | break; 44 | case EQ : 45 | filter=Filters.eq(attributeName, value); 46 | break; 47 | case NE : 48 | filter=Filters.ne(attributeName, value); 49 | break; 50 | default : 51 | filter=Filters.eq(attributeName, value); 52 | break; 53 | } 54 | return filter; 55 | } 56 | 57 | public static void logErrors(Exception e , ObjectId eventId){ 58 | SyncError error = new SyncError(e); 59 | error.setThreadName(Thread.currentThread().getName()); 60 | new SyncEventDao().pushError(eventId, error); 61 | } 62 | public static boolean getMongoClient(SyncConnectionInfo connectionInfo) { 63 | boolean flag = false; 64 | List addressList = null; 65 | List credList = null; 66 | MongoClient client = null; 67 | MongoClientOptions.Builder optionsBuilder = new MongoClientOptions.Builder(); 68 | optionsBuilder.readPreference(ReadPreference.secondary()); 69 | if (connectionInfo.getPassword() != null && !connectionInfo.getPassword().isEmpty()) { 70 | MongoCredential credential = MongoCredential.createCredential(connectionInfo.getUserName(), connectionInfo.getDbName(), 71 | connectionInfo.getPassword().toCharArray()); 72 | credList = new ArrayList(); 73 | credList.add(credential); 74 | } 75 | if (connectionInfo.getHostToPortMap() != null && !connectionInfo.getHostToPortMap().isEmpty()) { 76 | addressList = new ArrayList(); 77 | ServerAddress address = null; 78 | for (Map.Entry hostPort : connectionInfo.getHostToPortMap().entrySet()) { 79 | address = new ServerAddress(hostPort.getKey(), hostPort.getValue().intValue()); 80 | addressList.add(address); 81 | } 82 | } 83 | if(credList!=null){ 84 | client = new MongoClient(addressList, credList , optionsBuilder.build()); 85 | }else{ 86 | client = new MongoClient(addressList , optionsBuilder.build()); 87 | } 88 | if(client != null){ 89 | flag = true; 90 | client.close(); 91 | } 92 | return flag; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/app/dbmigrator/migratorapp/utilities/oracle/DbResourceUtils.java: -------------------------------------------------------------------------------- 1 | package com.cisco.app.dbmigrator.migratorapp.utilities.oracle; 2 | 3 | import java.sql.Connection; 4 | import java.sql.ResultSet; 5 | import java.sql.SQLException; 6 | import java.sql.Statement; 7 | 8 | import org.apache.log4j.Logger; 9 | 10 | public final class DbResourceUtils { 11 | private static Logger logger = Logger.getLogger(DbResourceUtils.class); 12 | private DbResourceUtils(){} 13 | public static void closeResources(ResultSet rset , Statement stmt, Connection connection){ 14 | if(rset!=null){ 15 | try { 16 | rset.close(); 17 | } catch (SQLException e) { 18 | logger.error("Error in closing Resultset" , e); 19 | } 20 | } 21 | if(stmt!=null){ 22 | try { 23 | stmt.close(); 24 | } catch (SQLException e) { 25 | logger.error("Error in closing Statement" , e); 26 | } 27 | } 28 | if(connection!=null){ 29 | try { 30 | connection.close(); 31 | } catch (SQLException e) { 32 | logger.error("Error in closing Connection" , e); 33 | } 34 | } 35 | } 36 | 37 | public static boolean isValidConnection(Connection con){ 38 | boolean isValid=true; 39 | try{ 40 | if(con==null || con.isClosed()){ 41 | logger.info("Connection is Null"); 42 | isValid=false; 43 | }else{ 44 | /*ValidConnection valCon= (ValidConnection) con; 45 | if(!valCon.isValid()){ 46 | logger.info("Connection is invalid"); 47 | isValid=false; 48 | valCon.setInvalid(); 49 | }*/ 50 | } 51 | }catch(SQLException e){ 52 | isValid=false; 53 | logger.error("Error in validating connection ",e); 54 | } 55 | return isValid; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/i/buttonBG-H.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/WEB-INF/views/i/buttonBG-H.jpg -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/jsp/footer.jsp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/WEB-INF/views/jsp/footer.jsp -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/jsp/header.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Insert title here 7 | 8 | 9 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | CiscoSync 6 | 7 | contextClass 8 | 9 | org.springframework.web.context.support.AnnotationConfigWebApplicationContext 10 | 11 | 12 | 13 | org.springframework.web.context.ContextLoaderListener 14 | 15 | 16 | SpringDispatcher 17 | org.springframework.web.servlet.DispatcherServlet 18 | 19 | contextClass 20 | 21 | org.springframework.web.context.support.AnnotationConfigWebApplicationContext 22 | 23 | 24 | 25 | contextConfigLocation 26 | com.cisco.app.dbmigrator.migratorapp 27 | 28 | 1 29 | 30 | 31 | SpringDispatcher 32 | / 33 | 34 | 35 | 36 | 56 | 57 | 58 | 59 | 60 | 30 61 | 62 | 63 | 64 | 65 | 66 | spring.profiles.active 67 | dev 68 | 69 | 70 | spring.profiles.default 71 | dev 72 | 73 | 74 | spring.liveBeansView.mbeanDomain 75 | dev 76 | 77 | 78 | 79 | jdbc/OrclDataSource 80 | javax.sql.DataSource 81 | Container 82 | Shareable 83 | 84 | -------------------------------------------------------------------------------- /src/main/webapp/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 30 24 | 2 25 | 2 26 | 2 27 | 20000 28 | true 29 | oracle.jdbc.pool.OracleDataSourceFactory 30 | select 1 from dual 31 | true 32 | true 33 | true 34 | 300 35 | true 36 | true 37 | 1800 38 | 180000 39 | 180000 40 | 200 41 | select 1 from dual 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 54 | -------------------------------------------------------------------------------- /src/main/webapp/resources/css/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/css/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/main/webapp/resources/css/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/css/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/main/webapp/resources/css/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/css/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/main/webapp/resources/css/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/css/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/main/webapp/resources/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /src/main/webapp/resources/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /src/main/webapp/resources/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /src/main/webapp/resources/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /src/main/webapp/resources/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /src/main/webapp/resources/js/DBMigratorApp.js: -------------------------------------------------------------------------------- 1 | var DBMigratorApp = angular.module('DBMigratorApp', [ 2 | 'ngRoute', 'smart-table', 'ngMaterial', 'ngAnimate', 'ui.bootstrap']); 3 | 4 | DBMigratorApp.config(['$routeProvider', '$locationProvider', 5 | function($routeProvider, $locationProvider) { 6 | $routeProvider. 7 | when('/', { 8 | isUser: function(user){ 9 | if(user){ 10 | return true; 11 | } else { 12 | return false; 13 | } 14 | } 15 | }).when('/SelectDB', { 16 | templateUrl: 'resources/templates/selectDBViewTemplates.html', 17 | controller: 'dbSelectionController' 18 | }).when('/Migrate', { 19 | templateUrl: 'resources/templates/migrateViewTemplates.html', 20 | authDB: function (user) { 21 | return user && user.NewData 22 | } 23 | }).when('/MigrateRev', { 24 | templateUrl: 'resources/templates/migrateViewReverseTemplates.html', 25 | authDB: function (user) { 26 | return user && user.NewData 27 | } 28 | }).when('/AdminPage', { 29 | templateUrl: 'resources/templates/adminPageTemplates.html', 30 | isAdmin: function (user) { 31 | return user && (user.userRole == "Admin") 32 | } 33 | }).when('/Home', { 34 | templateUrl: 'resources/templates/homeViewTemplates.html' 35 | }).otherwise({ 36 | }).when('/DBManager', { 37 | templateUrl: 'resources/templates/DBAssignManagerTemplates.html' 38 | }).otherwise({ 39 | template: '

Invalid URL :/

' 40 | }); 41 | // $locationProvider.html5Mode(false).hashPrefix('!'); 42 | } 43 | ]).run(function ($rootScope, $location) { 44 | $rootScope.$on('$routeChangeStart', function (ev, next, curr) { 45 | if(!next){ 46 | $location.path('/Home') ; 47 | } 48 | else if(next.$$route) { 49 | if(next.$$route.isUser){ 50 | var user = jsUserData; 51 | if(next.$$route.isUser(user)){ 52 | $location.path('/Home') ; 53 | } 54 | } 55 | if (next.$$route.authDB) { // On Migrate Page check if selections has been done. if not, redirect to DB selection page. 56 | var user = $rootScope.UserData 57 | var auth = next.$$route.authDB 58 | if (auth && !auth(user)) { 59 | $location.path('/SelectDB') ; 60 | } 61 | } 62 | 63 | if (next.$$route.isAdmin) { // On Migrate Page check if selections has been done. if not, redirect to DB selection page. 64 | var user = $rootScope.UserData 65 | var auth = next.$$route.isAdmin 66 | if (auth && !auth(user)) { 67 | $location.path('/Home') ; 68 | } 69 | } 70 | } 71 | }) 72 | }); 73 | -------------------------------------------------------------------------------- /src/main/webapp/resources/js/adminViewControllers.js: -------------------------------------------------------------------------------- 1 | DBMigratorApp.controller( 'adminViewController', function ($scope, popupFactory, devUtilities, $rootScope, $element, $timeout, dbUtilities, $http, $interval, DummyDataService){ 2 | var userdata = jsUserData; 3 | $rootScope.UserData = jsUserData; 4 | $rootScope.UserData.userRole = "Admin"; 5 | $scope.date = new Date(); 6 | 7 | $scope.stopNode = function(row){ 8 | 9 | }, 10 | 11 | $scope.init = function(){ 12 | $scope.loadNodes(); 13 | }, 14 | 15 | $scope.loadNodes = function(refreshCall){ 16 | $scope.isRefreshing = true; 17 | $http({ 18 | method: 'GET', 19 | url: 'getNodeDetails', 20 | params : {userId : $rootScope.UserData.userid} 21 | 22 | }).then(function successCallback(response) { 23 | if(refreshCall){ 24 | $scope.updateCollapseData(response.data); 25 | } else { 26 | $scope.adminNodesCollection = response.data; 27 | } 28 | $scope.isRefreshing = false; 29 | }); 30 | } 31 | 32 | // Restore the states of expansion for nodes after refresh 33 | $scope.updateCollapseData = function(newData){ 34 | $scope.expandData = {}; 35 | for (var i = 0; i < $scope.adminNodesCollection.length; i++) { 36 | var oNode = $scope.adminNodesCollection[i]; 37 | $scope.expandData[oNode._id.$oid] = oNode.isExpanded; 38 | }; 39 | $scope.adminNodesCollection.length = 0; 40 | newData.forEach(function(node, index){ 41 | node.isExpanded = $scope.expandData[node._id.$oid] ? $scope.expandData[node._id.$oid] : false; 42 | $scope.adminNodesCollection.push(node); 43 | }) 44 | } 45 | 46 | $scope.refreshNodeData = function(){ 47 | $scope.loadNodes(true); 48 | } 49 | 50 | $scope.init(); 51 | //$scope.adminNodesCollection = DummyDataService.getAdminPageDummyData(); 52 | }); 53 | 54 | 55 | DBMigratorApp.controller( 'serverNodesBlockController', function ($scope, popupFactory, devUtilities, $rootScope, $element, $timeout, dbUtilities, $http, $interval, DummyDataService){ 56 | if($scope.node.isExpanded == undefined){ 57 | $scope.node.isExpanded = false; 58 | } 59 | $scope.isEventsExpanded = true; 60 | 61 | if($scope.node && $scope.node.events){ 62 | console.log($scope.node.events); 63 | } 64 | 65 | $scope.expandNodes = function(){ 66 | $scope.node.isExpanded = !$scope.node.isExpanded; 67 | } 68 | $scope.expandEvents = function(){ 69 | $scope.isEventsExpanded = !$scope.isEventsExpanded; 70 | }; 71 | 72 | $scope.init = function(){ 73 | if($scope.node && $scope.node.events){ 74 | $scope.eventRowCollection = $scope.node.events.slice(); 75 | $scope.safeEventRowCollection = $scope.node.events.slice(); 76 | } 77 | } 78 | 79 | $scope.init(); 80 | }); 81 | 82 | -------------------------------------------------------------------------------- /src/main/webapp/resources/js/directives.js: -------------------------------------------------------------------------------- 1 | DBMigratorApp.directive('droppableArea', function(){ 2 | return { 3 | restrict: 'A', 4 | link: function(scope,element,attrs){ 5 | element.on("dragover", function(eventObject){ 6 | /* NOTE : dataTransfer.getData cannot be accessed in any event except "drop" as per specification of Chrome and IE. */ 7 | //console.log(eventObject.originalEvent.dataTransfer.getData("text")); 8 | eventObject.preventDefault(); // Allow to drop 9 | }); 10 | 11 | element.on("drop", function(eventObject) { 12 | if(attrs.callbackfn){ 13 | scope[attrs.callbackfn](eventObject); 14 | } else { 15 | console.log('Directive : droppableArea : Error : No Callback function defined on Drop event') 16 | } 17 | eventObject.preventDefault(); 18 | }); 19 | } 20 | } 21 | }); 22 | 23 | 24 | DBMigratorApp.directive('sortableDropArea', ['popupFactory', function(popupFactory){ 25 | return { 26 | restrict: 'A', 27 | link: function(scope,element,attrs){ 28 | element.on("dragover", function(eventObject){ 29 | element.addClass('sortable-drag-over'); 30 | eventObject.preventDefault(); // Allow to drop 31 | }); 32 | 33 | element.on("dragleave", function(eventObject){ 34 | element.removeClass('sortable-drag-over'); 35 | //eventObject.preventDefault(); // Allow to drop 36 | }); 37 | 38 | element.on("drop", function(eventObject) { 39 | element.removeClass('sortable-drag-over'); 40 | if(attrs.callbackfn){ 41 | scope[attrs.callbackfn](eventObject); 42 | } else { 43 | console.log('Directive : sortableDropArea : Error : No Callback function defined on Drop event') 44 | } 45 | /*var xferData = (JSON.parse(eventObject.originalEvent.dataTransfer.getData("text"))); 46 | if(scope.nodeGroup.nodeName == xferData.nodeName){ 47 | if(scope.data.name != xferData.tableName){ 48 | // Put the dragged element before current element in array 49 | if(attrs.callbackfn){ 50 | scope[attrs.callbackfn](eventObject); 51 | } else { 52 | console.log('Directive : sortableDropArea : Error : No Callback function defined on Drop event') 53 | } 54 | } 55 | } else { 56 | popupFactory.showInfoPopup('Access Denied!!', 'Only tables from same node can be rearranged !!.', false); 57 | }*/ 58 | eventObject.preventDefault(); 59 | }); 60 | } 61 | } 62 | }]); 63 | 64 | DBMigratorApp.directive('draggableElement', function(){ 65 | return { 66 | restrict: 'A', 67 | link: function(scope,element,attrs){ 68 | element.on('dragstart', function(ev){ 69 | if(attrs.xferData){ 70 | ev.originalEvent.dataTransfer.setData("text", attrs.xferData); 71 | } 72 | }); 73 | } 74 | } 75 | }); 76 | 77 | DBMigratorApp.directive('draggableText', function(){ 78 | return { 79 | restrict: 'E', 80 | template: '', 81 | replace: true, 82 | link: function(scope,element,attrs){ 83 | element.on('dragstart', function(ev){ 84 | 85 | /* NOTE : IE and CHROME only support "text" attribute while saving data in setData */ 86 | if(attrs.xferData){ 87 | ev.originalEvent.dataTransfer.setData("text", attrs.xferData); 88 | } else { 89 | ev.originalEvent.dataTransfer.setData("text", ev.target.textContent); 90 | } 91 | }); 92 | 93 | element.on('dragend', function(ev){ 94 | //scope.getColumns({name: element.textContent}); 95 | }) 96 | 97 | /* bind changes */ 98 | attrs.$observe('elemLabel', function(val){ 99 | element.text(val) 100 | }) 101 | } 102 | } 103 | }); -------------------------------------------------------------------------------- /src/main/webapp/resources/js/lib/angular-aria.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | AngularJS v1.4.8 3 | (c) 2010-2015 Google, Inc. http://angularjs.org 4 | License: MIT 5 | */ 6 | (function(u,n,v){'use strict';var r="BUTTON A INPUT TEXTAREA SELECT DETAILS SUMMARY".split(" "),p=function(a,c){if(-1!==c.indexOf(a[0].nodeName))return!0};n.module("ngAria",["ng"]).provider("$aria",function(){function a(a,f,l,m){return function(d,e,b){var g=b.$normalize(f);!c[g]||p(e,l)||b[g]||d.$watch(b[a],function(b){b=m?!b:!!b;e.attr(f,b)})}}var c={ariaHidden:!0,ariaChecked:!0,ariaDisabled:!0,ariaRequired:!0,ariaInvalid:!0,ariaMultiline:!0,ariaValue:!0,tabindex:!0,bindKeypress:!0,bindRoleForClick:!0}; 7 | this.config=function(a){c=n.extend(c,a)};this.$get=function(){return{config:function(a){return c[a]},$$watchExpr:a}}}).directive("ngShow",["$aria",function(a){return a.$$watchExpr("ngShow","aria-hidden",[],!0)}]).directive("ngHide",["$aria",function(a){return a.$$watchExpr("ngHide","aria-hidden",[],!1)}]).directive("ngModel",["$aria",function(a){function c(c,m,d){return a.config(m)&&!d.attr(c)}function k(a,c){return!c.attr("role")&&c.attr("type")===a&&"INPUT"!==c[0].nodeName}function f(a,c){var d= 8 | a.type,e=a.role;return"checkbox"===(d||e)||"menuitemcheckbox"===e?"checkbox":"radio"===(d||e)||"menuitemradio"===e?"radio":"range"===d||"progressbar"===e||"slider"===e?"range":"textbox"===(d||e)||"TEXTAREA"===c[0].nodeName?"multiline":""}return{restrict:"A",require:"?ngModel",priority:200,compile:function(l,m){var d=f(m,l);return{pre:function(a,b,c,h){"checkbox"===d&&"checkbox"!==c.type&&(h.$isEmpty=function(b){return!1===b})},post:function(e,b,g,h){function f(){return h.$modelValue}function m(){return q? 9 | (q=!1,function(a){a=g.value==h.$viewValue;b.attr("aria-checked",a);b.attr("tabindex",0-!a)}):function(a){b.attr("aria-checked",g.value==h.$viewValue)}}function l(){b.attr("aria-checked",!h.$isEmpty(h.$viewValue))}var q=c("tabindex","tabindex",b)&&!p(b,r);switch(d){case "radio":case "checkbox":k(d,b)&&b.attr("role",d);c("aria-checked","ariaChecked",b)&&e.$watch(f,"radio"===d?m():l);q&&b.attr("tabindex",0);break;case "range":k(d,b)&&b.attr("role","slider");if(a.config("ariaValue")){var n=!b.attr("aria-valuemin")&& 10 | (g.hasOwnProperty("min")||g.hasOwnProperty("ngMin")),s=!b.attr("aria-valuemax")&&(g.hasOwnProperty("max")||g.hasOwnProperty("ngMax")),t=!b.attr("aria-valuenow");n&&g.$observe("min",function(a){b.attr("aria-valuemin",a)});s&&g.$observe("max",function(a){b.attr("aria-valuemax",a)});t&&e.$watch(f,function(a){b.attr("aria-valuenow",a)})}q&&b.attr("tabindex",0);break;case "multiline":c("aria-multiline","ariaMultiline",b)&&b.attr("aria-multiline",!0)}h.$validators.required&&c("aria-required","ariaRequired", 11 | b)&&e.$watch(function(){return h.$error.required},function(a){b.attr("aria-required",!!a)});c("aria-invalid","ariaInvalid",b)&&e.$watch(function(){return h.$invalid},function(a){b.attr("aria-invalid",!!a)})}}}}}]).directive("ngDisabled",["$aria",function(a){return a.$$watchExpr("ngDisabled","aria-disabled",[])}]).directive("ngMessages",function(){return{restrict:"A",require:"?ngMessages",link:function(a,c,k,f){c.attr("aria-live")||c.attr("aria-live","assertive")}}}).directive("ngClick",["$aria","$parse", 12 | function(a,c){return{restrict:"A",compile:function(k,f){var l=c(f.ngClick,null,!0);return function(c,d,e){if(!p(d,r)&&(a.config("bindRoleForClick")&&!d.attr("role")&&d.attr("role","button"),a.config("tabindex")&&!d.attr("tabindex")&&d.attr("tabindex",0),a.config("bindKeypress")&&!e.ngKeypress))d.on("keypress",function(a){function d(){l(c,{$event:a})}var e=a.which||a.keyCode;32!==e&&13!==e||c.$apply(d)})}}}}]).directive("ngDblclick",["$aria",function(a){return function(c,k,f){!a.config("tabindex")|| 13 | k.attr("tabindex")||p(k,r)||k.attr("tabindex",0)}}])})(window,window.angular); 14 | //# sourceMappingURL=angular-aria.min.js.map 15 | -------------------------------------------------------------------------------- /src/main/webapp/resources/js/lib/angular-cookies.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | AngularJS v1.5.0-beta.2 3 | (c) 2010-2015 Google, Inc. http://angularjs.org 4 | License: MIT 5 | */ 6 | (function(p,c,n){'use strict';function l(b,a,g){var d=g.baseHref(),k=b[0];return function(b,e,f){var g,h;f=f||{};h=f.expires;g=c.isDefined(f.path)?f.path:d;c.isUndefined(e)&&(h="Thu, 01 Jan 1970 00:00:00 GMT",e="");c.isString(h)&&(h=new Date(h));e=encodeURIComponent(b)+"="+encodeURIComponent(e);e=e+(g?";path="+g:"")+(f.domain?";domain="+f.domain:"");e+=h?";expires="+h.toUTCString():"";e+=f.secure?";secure":"";f=e.length+1;4096 4096 bytes)!");k.cookie=e}}c.module("ngCookies",["ng"]).provider("$cookies",[function(){var b=this.defaults={};this.$get=["$$cookieReader","$$cookieWriter",function(a,g){return{get:function(d){return a()[d]},getObject:function(d){return(d=this.get(d))?c.fromJson(d):d},getAll:function(){return a()},put:function(d,a,m){g(d,a,m?c.extend({},b,m):b)},putObject:function(d,b,a){this.put(d,c.toJson(b),a)},remove:function(a,k){g(a,n,k?c.extend({},b,k):b)}}}]}]);c.module("ngCookies").factory("$cookieStore", 8 | ["$cookies",function(b){return{get:function(a){return b.getObject(a)},put:function(a,c){b.putObject(a,c)},remove:function(a){b.remove(a)}}}]);l.$inject=["$document","$log","$browser"];c.module("ngCookies").provider("$$cookieWriter",function(){this.$get=l})})(window,window.angular); 9 | //# sourceMappingURL=angular-cookies.min.js.map 10 | -------------------------------------------------------------------------------- /src/main/webapp/resources/js/lib/angular-messages.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | AngularJS v1.4.8 3 | (c) 2010-2015 Google, Inc. http://angularjs.org 4 | License: MIT 5 | */ 6 | (function(z,h,A){'use strict';function m(h){return["$animate",function(r){return{restrict:"AE",transclude:"element",terminal:!0,require:"^^ngMessages",link:function(n,f,a,g,l){var c=f[0],p,h=a.ngMessage||a.when;a=a.ngMessageExp||a.whenExp;var k=function(b){p=b?v(b)?b:b.split(/[\s,]+/):null;g.reRender()};a?(k(n.$eval(a)),n.$watchCollection(a,k)):k(h);var e,q;g.register(c,q={test:function(b){var a=p;b=a?v(a)?0<=a.indexOf(b):a.hasOwnProperty(b):void 0;return b},attach:function(){e||l(n,function(b){r.enter(b, 7 | null,f);e=b;var a=e.$$attachId=g.getAttachId();e.on("$destroy",function(){e&&e.$$attachId===a&&(g.deregister(c),q.detach())})})},detach:function(){if(e){var b=e;e=null;r.leave(b)}}})}}}]}var v=h.isArray,w=h.forEach,x=h.isString,y=h.element;h.module("ngMessages",[]).directive("ngMessages",["$animate",function(h){function r(f,a){return x(a)&&0===a.length||n(f.$eval(a))}function n(f){return x(f)?f.length:!!f}return{require:"ngMessages",restrict:"AE",controller:["$element","$scope","$attrs",function(f, 8 | a,g){function l(b,a){for(var d=a,f=[];d&&d!==b;){var c=d.$$ngMessageNode;if(c&&c.length)return k[c];d.childNodes.length&&-1==f.indexOf(d)?(f.push(d),d=d.childNodes[d.childNodes.length-1]):d=d.previousSibling||d.parentNode}}var c=this,p=0,m=0;this.getAttachId=function(){return m++};var k=this.messages={},e,q;this.render=function(b){b=b||{};e=!1;q=b;for(var p=r(a,g.ngMessagesMultiple)||r(a,g.multiple),d=[],k={},s=c.head,l=!1,m=0;null!=s;){m++;var t=s.message,u=!1;l||w(b,function(a,b){!u&&n(a)&&t.test(b)&& 9 | !k[b]&&(u=k[b]=!0,t.attach())});u?l=!p:d.push(t);s=s.next}w(d,function(b){b.detach()});d.length!==m?h.setClass(f,"ng-active","ng-inactive"):h.setClass(f,"ng-inactive","ng-active")};a.$watchCollection(g.ngMessages||g["for"],c.render);this.reRender=function(){e||(e=!0,a.$evalAsync(function(){e&&q&&c.render(q)}))};this.register=function(b,a){var d=p.toString();k[d]={message:a};var e=f[0],g=k[d];c.head?(e=l(e,b))?(g.next=e.next,e.next=g):(g.next=c.head,c.head=g):c.head=g;b.$$ngMessageNode=d;p++;c.reRender()}; 10 | this.deregister=function(b){var a=b.$$ngMessageNode;delete b.$$ngMessageNode;var d=k[a];(b=l(f[0],b))?b.next=d.next:c.head=d.next;delete k[a];c.reRender()}}]}}]).directive("ngMessagesInclude",["$templateRequest","$document","$compile",function(h,m,n){return{restrict:"AE",require:"^^ngMessages",link:function(f,a,g){var l=g.ngMessagesInclude||g.src;h(l).then(function(c){n(c)(f,function(c){a.after(c);c=y(m[0].createComment(" ngMessagesInclude: "+l+" "));a.after(c);a.remove()})})}}}]).directive("ngMessage", 11 | m("AE")).directive("ngMessageExp",m("A"))})(window,window.angular); 12 | //# sourceMappingURL=angular-messages.min.js.map 13 | -------------------------------------------------------------------------------- /src/main/webapp/resources/js/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/js/logo.png -------------------------------------------------------------------------------- /src/main/webapp/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Set root logger level to DEBUG and its only appender to CONSOLE, SYNC. 2 | # CONSOLE is set to be a ConsoleAppender. 3 | log4j.rootLogger=FILE,CONSOLE 4 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 5 | 6 | # A1 uses PatternLayout. 7 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS Z} [%t] %-5p %c %x - %m%n 9 | 10 | log4j.appender.FILE=org.apache.log4j.RollingFileAppender 11 | log4j.appender.FILE.layout=org.apache.log4j.PatternLayout 12 | log4j.appender.FILE.File=$SYNC_HOME\sync.log 13 | log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS Z}[%t] %-5p %c %x - %m%n 14 | log4j.appender.FILE.MaxFileSize=256KB 15 | log4j.appender.FILE.MaxBackupIndex=50 16 | log4j.appender.org.springframework=INFO -------------------------------------------------------------------------------- /src/main/webapp/resources/logo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/logo/logo.png -------------------------------------------------------------------------------- /src/main/webapp/resources/sync/certs/keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/sync/certs/keystore -------------------------------------------------------------------------------- /src/main/webapp/resources/sync/certs/trustStore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gagoyal01/mongodb-rdbms-sync/2e726c551dd29b26a364e1d5c43e0e6576f78f31/src/main/webapp/resources/sync/certs/trustStore -------------------------------------------------------------------------------- /src/main/webapp/resources/sync/db-props/dev.properties: -------------------------------------------------------------------------------- 1 | #dbname=ccwcddev 2 | #username=ccwApp 3 | #password=b71f1ad55ba5519848130ffa9b887dc8 4 | #port=27048 5 | #host=mngdb-ccw-cd-dev-01,mngdb-ccw-cd-dev-02,mngdb-ccw-cd-dev-03 6 | 7 | dbname=ccwlt 8 | username=ccwApp 9 | password=8b9922d6b71738d0713ada928b5d15ae 10 | port=27058 11 | host=mngdb-ccw-lt1-01,mngdb-ccw-lt1-02,mngdb-ccw-lt2-01,mngdb-ccw-lt2-02,mngdb-ccw-lt3-01 -------------------------------------------------------------------------------- /src/main/webapp/resources/sync/db-props/local.properties: -------------------------------------------------------------------------------- 1 | dbname=ccwlt 2 | username=ccwApp 3 | password=ccw16ltApp 4 | port=27058 5 | host=mngdb-ccw-lt1-01,mngdb-ccw-lt1-02,mngdb-ccw-lt2-01,mngdb-ccw-lt2-02,mngdb-ccw-lt3-01 -------------------------------------------------------------------------------- /src/main/webapp/resources/sync/db-props/lt.properties: -------------------------------------------------------------------------------- 1 | dbname=ccwdev 2 | username=ccwApp 3 | password=4b5fb0d73636d8388da41ce4cbd0565c 4 | encrypted=true 5 | port=27048 6 | host=mngdb-ccw-dev-01,mngdb-ccw-dev-02,mngdb-ccw-dev-03 -------------------------------------------------------------------------------- /src/main/webapp/resources/sync/db-props/prod.properties: -------------------------------------------------------------------------------- 1 | dbname=ccwprd 2 | username=ccwApp 3 | password=1d5ad9e5d203744d1b1c4f8cc8c58c13 4 | encrypted=true 5 | port=27038 6 | host=mngdb-ccw-prd1-03,mngdb-ccw-prd1-04,mngdb-ccw-prd2-03,mngdb-ccw-prd2-04,mngdb-ccw-prd3-03 -------------------------------------------------------------------------------- /src/main/webapp/resources/sync/db-props/stage.properties: -------------------------------------------------------------------------------- 1 | dbname=ccwlt 2 | username=ccwApp 3 | password=8b9922d6b71738d0713ada928b5d15ae 4 | encrypted=true 5 | port=27058 6 | host=mngdb-ccw-lt1-01,mngdb-ccw-lt1-02,mngdb-ccw-lt2-01,mngdb-ccw-lt2-02,mngdb-ccw-lt3-01 -------------------------------------------------------------------------------- /src/main/webapp/resources/sync/mailer.properties: -------------------------------------------------------------------------------- 1 | mail.smtp.host=outbound.cisco.com 2 | protocol=smtp 3 | mail.smtp.port=25 4 | fromAlias=donotreply@cisco.com 5 | teamAlias=sync_dev -------------------------------------------------------------------------------- /src/main/webapp/resources/sync/sync.conf: -------------------------------------------------------------------------------- 1 | LIFE=local 2 | APP_ID=local 3 | KEYSTORE_NAME=keystore 4 | KEYSTORE_PASS=temp1234 5 | TRUSTSTORE_NAME=truststore 6 | TRUSTSTORE_PASS=temp1234 7 | LOGGING_LEVEL=INFO 8 | SYNC_USER=pnilayam -------------------------------------------------------------------------------- /src/main/webapp/resources/templates/plugInTemplates.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 46 | 47 | -------------------------------------------------------------------------------- /src/main/webapp/resources/templates/selectDBViewTemplates.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |
6 |

{{section.title}} :

  
7 | 8 | 19 |
20 | 21 | 32 | 33 |
34 |
35 |
36 |
37 | 38 |
39 |
40 |
--------------------------------------------------------------------------------