public QueryMetadataService getMetadataService(String reponame) { if (metadataServicesMap.get(reponame) == null) { IMetadataService metaService = repoService.getRepository(reponame).getMetadataService(); metadataServicesMap.put(reponame, new QueryMetadataService(metaService)); } return metadataServicesMap.get(reponame); }
private void createIndexesOnCollection(IPersistenceService persistenceService, String repoName, boolean isMainBranch, PersistenceContext context) { Repository repo = repositoryService.getRepository(repoName); List<MetaClass> metasInRepo = repo.getMetadataService().getMetaClasses(new MetadataContext(true, true)); if (metasInRepo.size() > 0) { persistenceService.ensureIndex(metasInRepo, context, isMainBranch); } }
@Test public void testLoadRepositories() { IRepositoryService repoService = RepositoryServiceFactory.createRepositoryService(ds, "localCMSServer"); Repository repo = repoService.getRepository("raptor-paas"); Assert.assertEquals("raptor-paas", repo.getRepositoryName()); repo = repoService.getRepository("software-deployment"); Assert.assertEquals("software-deployment", repo.getRepositoryName()); }
public MetaClass updateMetaField(CMSPriority p, String repoName, MetaClass meta, String fieldName, MetadataContext context) { logger.info("cms updateMetaField: {}, {}, {}, {}", new Object[] { repoName, meta.getName(), fieldName, context.getSourceIp() }); checkServerState(p, true); Repository repo = repositoryService.getRepository(repoName); context.setDbConfig(dbConfig); MetaClass metaClass = repo.getMetadataService().updateMetaField(meta, fieldName, context); // ensure index updateMetadataIndexOnBranch(metaClass.getName(), context, repo); return metaClass; }
public static TestDataLoader getDataLoader(MongoDataSource dataSource, String repoName){ IRepositoryService repoService = RepositoryServiceFactory.createRepositoryService(dataSource, "localCMSServer"); Repository repo = repoService.getRepository(repoName); IPersistenceService persistService = new PersistenceServiceImpl(dataSource); TestDataLoader loader = new TestDataLoader(repo, persistService, dataSource); return loader; }
public static TestDataLoader getDataLoader(MongoDataSource dataSource, String repoName){ IRepositoryService repoService = RepositoryServiceFactory.createRepositoryService(dataSource, "localCMSServer"); Repository repo = repoService.getRepository(repoName); IPersistenceService persistService = new NewPersistenceServiceImpl(dataSource); TestDataLoader loader = new TestDataLoader(repo, persistService, dataSource); return loader; }
@Test (expected=CmsDalException.class) public void testJsonEntity04(){ MetaClass instCls = repoService.getRepository(RAPTOR_REPO).getMetadataService().getMetaClass(SERVICE_INSTANCE); new JsonEntity(instCls, "{a:b}"); }
private IEntity buildQueryEntity(String reponame, String branchname, String metadata, String oid) { MetaClass meta = repoService.getRepository(reponame).getMetadataService().getMetaClass(metadata); IEntity queryEntity = new JsonEntity(meta); queryEntity.setId(oid); queryEntity.setBranchId(branchname); return queryEntity; }
protected JsonEntity newServiceInstance(String branchId){ String metaType = SERVICE_INSTANCE; MetaClass instCls = repoService.getRepository(RAPTOR_REPO).getMetadataService().getMetaClass(metaType); JsonEntity newEntity = new JsonEntity(instCls); newEntity.setBranchId(branchId); newEntity.addFieldValue("name", "Dummy Service Instance for Entity-Branch Test"); return newEntity; }
@Test public void testJsonEntity01(){ JsonEntity newInst = newServiceInstance(IBranch.DEFAULT_BRANCH); MetaClass instCls = repoService.getRepository(RAPTOR_REPO).getMetadataService().getMetaClass(SERVICE_INSTANCE); JsonEntity entity = new JsonEntity(instCls, newInst.getNode().toString()); Assert.assertNotNull(entity); }
@Test public void testCreateWithDateDefault() { MetaClass manifestMeta = repoService.getRepository(DEPLOY_REPO).getMetadataService().getMetaClass(MANIFEST); MetaAttribute timeField = (MetaAttribute) manifestMeta.getFieldByName(LAST_MODIFIED_TIME); Assert.assertEquals("$NOW", timeField.getDefaultValue()); IEntity jsonEntity = newManifest(IBranch.DEFAULT_BRANCH); entityService.create(jsonEntity, context); }
private JsonEntity newServiceInstance(String branchId, String name){ String metaType = "ServiceInstance"; MetaClass instCls = repoService.getRepository(RAPTOR_REPO).getMetadataService().getMetaClass(metaType); JsonEntity newEntity = new JsonEntity(instCls); newEntity.setBranchId(branchId); newEntity.addFieldValue("name", name); return newEntity; }
@AfterClass public static void tear() { cleanTestData(); Repository repository = repoService.getRepository(RAPTOR_REPO); repository.getOptions().setMaxIndexedArraySize(null); repoService.updateRepository(repository); ServiceFactory.clearServiceCaches(); }
@Test public void testDeleteMetaField() { IMetadataService metaService = repositoryService.getRepository("software-deployment").getMetadataService(); MetadataContext metaContext = new MetadataContext(); String className = "ServiceCluster"; metaService.deleteMetaField(className, "name", metaContext); MetaClass meta = metaService.getMetaClass(className); Assert.assertNull(meta.getFieldByName("name")); }
private JsonEntity newNetworkAddress(String branchId){ String metaType = "NetworkAddress"; MetaClass instCls = repoService.getRepository(CMSDB_REPO).getMetadataService().getMetaClass(metaType); JsonEntity newEntity = new JsonEntity(instCls); newEntity.setBranchId(branchId); newEntity.addFieldValue("address", "127.0.0.1"); newEntity.addFieldValue("ipVersion", "IPv4"); newEntity.addFieldValue("resourceId", "Dummy NodeServer for Entity-Branch Test:" + (appCount++)); return newEntity; }
private static JsonEntity newApplicationService(String baseName) { String metaType = APPLICATION_SERVICE; MetaClass instCls = repoService.getRepository(RAPTOR_REPO).getMetadataService().getMetaClass(metaType); JsonEntity newEntity = new JsonEntity(instCls); newEntity.setCreator("unitTestUser"); newEntity.setBranchId(IBranch.DEFAULT_BRANCH); newEntity.addFieldValue("name", generateRandomName(baseName)); return newEntity; }
protected JsonEntity newNetworkAddress(String branchId, int seq){ String metaType = NETWORK_ADDRESS; MetaClass instCls = repoService.getRepository(STRATUS_REPO).getMetadataService().getMetaClass(metaType); JsonEntity newEntity = new JsonEntity(instCls); newEntity.setBranchId(branchId); newEntity.addFieldValue("ipaddress", "1011.249.64.99"); newEntity.addFieldValue("hostname", "a.ebay.com"); newEntity.addFieldValue("zone", "corp"); newEntity.addFieldValue(_802_ADDRESS, "00:e0:ce:af:" + seq); return newEntity; }
@BeforeClass public static void setupData() { MongoDataSource ds = new MongoDataSource(getConnectionString()); MetadataDataLoader.getInstance(ds).loadTestDataFromResource(); raptorMetaService = RepositoryServiceFactory.createRepositoryService(ds, "localCMSServer") .getRepository(RAPTOR_REPO).getMetadataService(); serviceInstanceMetadata = raptorMetaService.getMetaClass("ServiceInstance"); appServiceMetadata = raptorMetaService.getMetaClass("ApplicationService"); environmentMeta = raptorMetaService.getMetaClass("Environment"); }
@BeforeClass public static void setupData() { MongoDataSource ds = new MongoDataSource(getConnectionString()); MetadataDataLoader.getInstance(ds).loadTestDataFromResource(); raptorMetaService = RepositoryServiceFactory.createRepositoryService(ds, "localCMSServer") .getRepository(RAPTOR_REPO).getMetadataService(); appServiceMetadata = raptorMetaService.getMetaClass("ApplicationService"); serviceInstanceMetadata = raptorMetaService.getMetaClass("ServiceInstance"); computeMetadata = raptorMetaService.getMetaClass("Compute"); }
@Test public void testCreateValidation_dateDefault2() { IMetadataService ms = repositoryService.getRepository(repoName).getMetadataService(); MetaClass metaClass = createMetaClass(); metaClass.setName("create2"); MetaAttribute b = new MetaAttribute(); b.setName("dateMeta2"); b.setDataType(DataTypeEnum.DATE); b.setDefaultValue("$NOW"); metaClass.addField(b); ms.createMetaClass(metaClass, new MetadataContext()); }