コード例 #1
0
    def getBackupFiles(self, databases, dbList, hostId, oshvResult):
        result = HashMap()
        query = Util.replace(Queries.DATABASE_BACKUP_FILES, dbList)
        rs = self.connection.getTable(query)
        disks = ArrayList()
        while rs.next():
            currentDbName = rs.getString("name")
            path = rs.getString("path")
            if path is not None:
                #extract the path
                path = Util.replaceFileSeparator(path)
                disk = Util.getDisk(path, hostId)
                disks.add(disk)

                fileName = Util.getFileFromPath(path)
                path = Util.getPath(path)
                configFileOsh = modeling.createConfigurationDocumentOSH(
                    fileName, path, None, hostId)
                result.put(currentDbName, configFileOsh)

        itr = disks.iterator()
        while itr.hasNext():
            oshvResult.add(itr.next())
        rs.close()
        return result
コード例 #2
0
    def getPublications(self, publisherName, publisherSqlServer, publisher,
                        oshv, sqlServerId):
        logger.debug('going to get publisher: ', publisherName)
        query = Util.replace(Queries.PUBLICATION_FROM_DISTRIBUTOR,
                             publisherName)
        rs = self.connection.doCall(query)
        publications = ArrayList()
        #we connect the publication to the database using container_f
        while (rs.next()):
            databaseName = rs.getString('publisher_db')
            publicationName = rs.getString('publication')
            type = rs.getInt('publication_type')
            publication = ObjectStateHolder('sqlserverpublication')
            db = self.getDatabase(publisherSqlServer, databaseName)
            publication.setAttribute(Queries.DATA_NAME, publicationName)
            publication.setContainer(db)
            publication.setAttribute('publicationType',
                                     PUBLICATION_TYPE[int(type)])
            oshv.add(db)
            oshv.add(publication)
            publications.add(publication)
        rs.close()
        logger.debug('got publications: ', publications.toString())

        #after we finished with the publication, we should get the subscription, this could be very very tricky!!!
        itr = publications.iterator()
        while (itr.hasNext()):
            publication = itr.next()
            publicationDbName = publication.getAttribute(
                Queries.DATA_NAME).getValue()
            values = [
                publisherName, publicationDbName,
                publication.getAttribute(Queries.DATA_NAME).getValue()
            ]
            query = Util.replaceAllByArray(
                Queries.SUBSCRIPTIONS_FROM_DISRIBUTOR_BY_PUBLICATION, values)
            rs = self.connection.doCall(query)
            while (rs.next()):
                subscriberName = rs.getString('subscriber')
                sqlServer = self.createSqlServer(subscriberName, oshv,
                                                 sqlServerId)
                #create the subscriber object and the subscription:
                databaseName = rs.getString('subscriber_db')
                subscription = ObjectStateHolder('sqlserversubscription')
                subscription.setAttribute(Queries.DATA_NAME, databaseName)
                sd = self.getDatabase(sqlServer, databaseName)
                subscription.setContainer(sd)
                logger.debug('got subscription: ', subscriberName, " : ",
                             'databaseName')
                oshv.add(sqlServer)
                oshv.add(sd)
                oshv.add(subscription)
                #create the database and the links:
                #let try the replicated link
                pd = self.getDatabase(publisherSqlServer, publicationDbName)
                oshv.add(modeling.createLinkOSH('replicated', pd, sd))
            rs.close()
コード例 #3
0
ファイル: test_iterators.py プロジェクト: karpierz/jtypes.jep
 def test_iteration(self):
     from java.util import ArrayList
     x = ArrayList()
     x.add("abc")
     x.add("adef")
     x.add("ahi")
     itr = x.iterator()
     for i in x:
         self.assertIn("a", i)
コード例 #4
0
ファイル: test_iterators.py プロジェクト: ndjensen/jep
 def test_iteration(self):
     from java.util import ArrayList
     x = ArrayList()
     x.add("abc")
     x.add("adef")
     x.add("ahi")
     itr = x.iterator()
     for i in x:
         self.assertIn("a", i)
コード例 #5
0
    def getPublications(self,publisherName,publisherSqlServer,publisher,oshv,sqlServerId):
        logger.debug('going to get publisher: ', publisherName)
        query = Util.replace(Queries.PUBLICATION_FROM_DISTRIBUTOR,publisherName)
        rs = self.connection.doCall(query)
        publications = ArrayList()
        #we connect the publication to the database using container_f
        while(rs.next()):
            databaseName = rs.getString('publisher_db')
            publicationName = rs.getString('publication')
            type = rs.getInt('publication_type')
            publication = ObjectStateHolder('sqlserverpublication')
            db = self.getDatabase(publisherSqlServer,databaseName)
            publication.setAttribute(Queries.DATA_NAME,publicationName)
            publication.setContainer(db)
            publication.setAttribute('publicationType',PUBLICATION_TYPE[int(type)])
            oshv.add(db)
            oshv.add(publication)
            publications.add(publication)
        rs.close()
        logger.debug('got publications: ', publications.toString())

        #after we finished with the publication, we should get the subscription, this could be very very tricky!!!
        itr = publications.iterator()
        while (itr.hasNext()):
            publication = itr.next()
            publicationDbName = publication.getAttribute(Queries.DATA_NAME).getValue()
            values = [publisherName,publicationDbName,publication.getAttribute(Queries.DATA_NAME).getValue()] 
            query = Util.replaceAllByArray(Queries.SUBSCRIPTIONS_FROM_DISRIBUTOR_BY_PUBLICATION,values)
            rs = self.connection.doCall(query)
            while (rs.next()):
                subscriberName = rs.getString('subscriber')
                sqlServer = self.createSqlServer(subscriberName,oshv,sqlServerId)
                #create the subscriber object and the subscription:
                databaseName = rs.getString('subscriber_db')
                subscription = ObjectStateHolder('sqlserversubscription')
                subscription.setAttribute(Queries.DATA_NAME,databaseName)
                sd = self.getDatabase(sqlServer,databaseName)
                subscription.setContainer(sd)
                logger.debug('got subscription: ', subscriberName, " : ", 'databaseName')
                oshv.add(sqlServer)
                oshv.add(sd)
                oshv.add(subscription)
                #create the database and the links:
                #let try the replicated link
                pd = self.getDatabase(publisherSqlServer,publicationDbName)
                oshv.add(modeling.createLinkOSH('replicated',pd,sd))
            rs.close()
コード例 #6
0
def tokens_to_instances(MALLET_FILE='../track_tokens.mallet',
                        token_file='../vocab/tokens.h5'):
    h5 = HDF5Factory.openForReading(token_file)

    ts2fs = TokenSequence2FeatureSequence()
    instances = InstanceList(ts2fs)

    instance_list = ArrayList()

    for track in h5.object().getGroupMembers('/'):
        track_data = []
        dtypes = h5.object().getGroupMembers('/' + track)
        if set(dtypes) != valid_data_types:
            continue
        for dtype in valid_data_types:
            dset = "/{}/{}".format(track, dtype)
            data = h5.readIntArray(dset)
            track_data.extend([dtype + str(x) for x in data])
        ts = TokenSequence(track_data)
        instance_list.add(Instance(ts, None, track, None))

    instances.addThruPipe(instance_list.iterator())

    saveInstanceList(instances, MALLET_FILE)
コード例 #7
0
ファイル: DatabaseProps.py プロジェクト: ddonnelly19/dd-git
    def getBackupFiles(self,databases,dbList,hostId,oshvResult):
        result = HashMap()
        query = Util.replace(Queries.DATABASE_BACKUP_FILES,dbList)
        rs = self.connection.getTable(query)
        disks = ArrayList()
        while rs.next():
            currentDbName = rs.getString("name")
            path = rs.getString("path")
            if path is not None:
                #extract the path
                path = Util.replaceFileSeparator(path)
                disk = Util.getDisk(path,hostId)
                disks.add(disk)

                fileName = Util.getFileFromPath(path)
                path =  Util.getPath(path)
                configFileOsh = modeling.createConfigurationDocumentOSH(fileName, path, None, hostId)
                result.put(currentDbName, configFileOsh)

        itr = disks.iterator()
        while itr.hasNext():
            oshvResult.add(itr.next())
        rs.close()
        return result
コード例 #8
0
def tokens_to_instances(MALLET_FILE='../track_tokens.mallet',
                        token_file='../vocab/tokens.h5'):
    h5 = HDF5Factory.openForReading(token_file)

    ts2fs = TokenSequence2FeatureSequence()
    instances = InstanceList(ts2fs)

    instance_list = ArrayList()

    for track in h5.object().getGroupMembers('/'):
        track_data = []
        dtypes = h5.object().getGroupMembers('/' + track)
        if set(dtypes) != valid_data_types:
            continue
        for dtype in valid_data_types:
            dset = "/{}/{}".format(track, dtype)
            data = h5.readIntArray(dset)
            track_data.extend([dtype + str(x) for x in data])
        ts = TokenSequence(track_data)
        instance_list.add(Instance(ts, None, track, None))

    instances.addThruPipe(instance_list.iterator())

    saveInstanceList(instances, MALLET_FILE)