public static MetaClass getMetaClass(Repository repoInst) { IMetadataService metaService = repoInst.getMetadataService(); MetaClass historyMetaClass = metaService.getMetaClass(NAME); if (historyMetaClass != null) { return historyMetaClass; } throw new RuntimeException("no history meta class found"); }
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); } }
@Override public void ensureHistoryIndex(Repository repo, MetaClass meta) { List<MetaClass> metas = new ArrayList<MetaClass>(); metas.add(meta); PersistenceContext context = new PersistenceContext(repo.getMetadataService(), DBCollectionPolicy.Merged, ConsistentPolicy.safePolicy(), CMSConsts.METACLASS_HISTORY_COLL); context.setRegistration(getDalRegistration(new MetadataContext())); persistenceService.ensureIndex(metas, context, true); }
public MetaClass getMetaClass(CMSPriority p, String repoName, String metaclassName, int version) { Repository repo = repositoryService.getRepository(repoName); MetadataContext context = new MetadataContext(); context.setDbConfig(dbConfig); return repo.getMetadataService().getMetaClass(metaclassName, version, context); }
@Override public void validateMetaClass(String className) { MetaClass meta = repo.getMetadataService().getMetaClass(className); if (meta == null) { throw new MetaClassNotExistsException(repo.getRepositoryName(), className); } validator.validate(meta); }
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; }
@Test (expected=CmsDalException.class) public void testJsonEntity04(){ MetaClass instCls = repoService.getRepository(RAPTOR_REPO).getMetadataService().getMetaClass(SERVICE_INSTANCE); new JsonEntity(instCls, "{a:b}"); }
@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; }
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); }
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; }
private void prepareEmtpyEmbededArray() { EntityContext context = newEntityContext(); MetaClass roomMetadata = repositoryService.getRepository(RAPTOR_REPO).getMetadataService() .getMetaClass("Person"); JsonEntity modifyEntity = new JsonEntity(roomMetadata); modifyEntity.setBranchId(IBranch.DEFAULT_BRANCH); modifyEntity.setId("Dep!dep005!team!team510!person!person511"); modifyEntity.addFieldValue("address", "ddd"); entityService.pullField(modifyEntity, modifyEntity, "address", context); }
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; }
@Test public void testIndexes() { MetaClass mc = repo.getMetadataService().getMetaClass(APPLICATION_SERVICE); Assert.assertNull(mc.getIndexByName("non-index")); Assert.assertNotNull(mc.getIndexByName("appNameIndex")); Assert.assertNotNull(mc.getIndexNames()); }
@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"); }