当前位置: 首页>>代码示例>>Java>>正文


Java Node类代码示例

本文整理汇总了Java中org.ligoj.app.model.Node的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Node类属于org.ligoj.app.model包,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSubscriptionActivities

import org.ligoj.app.model.Node; //导入依赖的package包/类
@Test
public void addSubscriptionActivities() throws Exception {
	final LdapPluginResource resource = new LdapPluginResource();
	final Map<String, Map<String, Activity>> activities = new HashMap<>();
	final Subscription susbscription = new Subscription();
	final Node service = new Node();
	service.setId("J1");
	susbscription.setNode(service);
	susbscription.setId(1);
	final SampleActivityProvider plugin = Mockito.mock(SampleActivityProvider.class);
	final Map<String, Activity> activities1 = new HashMap<>();
	final Activity activity2 = new Activity();
	activities1.put(DEFAULT_USER, activity2);
	Mockito.when(plugin.getActivities(1, null)).thenReturn(activities1);
	final Set<INamableBean<String>> nodes = new HashSet<>();
	resource.addSubscriptionActivities(activities, null, susbscription, plugin, nodes);
	Assert.assertEquals(1, activities.size());
	Assert.assertTrue(activities.containsKey(DEFAULT_USER));
	Assert.assertEquals(1, activities.get(DEFAULT_USER).size());
	Assert.assertTrue(activities.get(DEFAULT_USER).containsKey("J1"));
	Assert.assertEquals(activity2, activities.get(DEFAULT_USER).get("J1"));
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:23,代码来源:LdapPluginResourceTest.java

示例2: addSubscriptionActivitiesDuplicateUser

import org.ligoj.app.model.Node; //导入依赖的package包/类
@Test
public void addSubscriptionActivitiesDuplicateUser() throws Exception {
	final LdapPluginResource resource = new LdapPluginResource();
	final Map<String, Map<String, Activity>> activities = new HashMap<>();
	activities.put(DEFAULT_USER, new HashMap<>());
	final Activity activity1 = new Activity();
	activities.get(DEFAULT_USER).put("J0", activity1);
	final Subscription susbscription = new Subscription();
	final Node service = new Node();
	service.setId("J1");
	susbscription.setNode(service);
	susbscription.setId(1);
	final SampleActivityProvider plugin = Mockito.mock(SampleActivityProvider.class);
	final Map<String, Activity> activities1 = new HashMap<>();
	final Activity activity2 = new Activity();
	activities1.put(DEFAULT_USER, activity2);
	Mockito.when(plugin.getActivities(1, null)).thenReturn(activities1);
	final Set<INamableBean<String>> nodes = new HashSet<>();
	resource.addSubscriptionActivities(activities, null, susbscription, plugin, nodes);
	Assert.assertEquals(1, activities.size());
	Assert.assertTrue(activities.containsKey(DEFAULT_USER));
	Assert.assertEquals(2, activities.get(DEFAULT_USER).size());
	Assert.assertTrue(activities.get(DEFAULT_USER).containsKey("J1"));
	Assert.assertEquals(activity1, activities.get(DEFAULT_USER).get("J0"));
	Assert.assertEquals(activity2, activities.get(DEFAULT_USER).get("J1"));
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:27,代码来源:LdapPluginResourceTest.java

示例3: newLdap

import org.ligoj.app.model.Node; //导入依赖的package包/类
private void newLdap() {
	final Node ldap = new Node();
	ldap.setId("service:id:ldap:secondary");
	ldap.setRefined(nodeRepository.findOneExpected("service:id:ldap"));
	ldap.setName("LDAP Test");
	nodeRepository.saveAndFlush(ldap);
	persistParameter(ldap, LdapPluginResource.PARAMETER_URL, "ldap://localhost:34389/");
	persistParameter(ldap, LdapPluginResource.PARAMETER_USER, "uid=admin,ou=system");
	persistParameter(ldap, LdapPluginResource.PARAMETER_PASSWORD, "secret");
	persistParameter(ldap, LdapPluginResource.PARAMETER_BASE_BN, "");
	persistParameter(ldap, LdapPluginResource.PARAMETER_UID_ATTRIBUTE, "uid");
	persistParameter(ldap, LdapPluginResource.PARAMETER_PEOPLE_DN, "dc=sample,dc=com");
	persistParameter(ldap, LdapPluginResource.PARAMETER_DEPARTMENT_ATTRIBUTE, "departmentNumber");
	persistParameter(ldap, LdapPluginResource.PARAMETER_LOCAL_ID_ATTRIBUTE, "employeeNumber");
	persistParameter(ldap, LdapPluginResource.PARAMETER_PEOPLE_CLASS, "inetOrgPerson");
	persistParameter(ldap, LdapPluginResource.PARAMETER_COMPANY_PATTERN, "gfi");
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:18,代码来源:LdapPluginResourceTest.java

示例4: updateCatalog

import org.ligoj.app.model.Node; //导入依赖的package包/类
/**
 * Update the catalog prices of related provider. Asynchronous operation.
 * 
 * @param node
 *            The node (provider) to update.
 * @return The catalog status.
 */
@POST
@Path("catalog/{node:service:prov:.+}")
public ImportCatalogStatus updateCatalog(@PathParam("node") final String node) {
	final Node entity = nodeResource.checkWritableNode(node).getTool();
	final ImportCatalogService catalogService = locator.getResource(entity.getId(), ImportCatalogService.class);
	final ImportCatalogStatus task = startTask(entity.getId(), t -> {
		t.setLocation(null);
		t.setNbInstancePrices(null);
		t.setNbInstanceTypes(null);
		t.setNbStorageTypes(null);
		t.setWorkload(0);
		t.setDone(0);
		t.setPhase(null);
	});
	final String user = securityHelper.getLogin();
	// The import execution will done into another thread
	Executors.newSingleThreadExecutor().submit(() -> {
		Thread.sleep(50);
		securityHelper.setUserName(user);
		updateCatalog(catalogService, entity.getId());
		return null;
	});
	return task;
}
 
开发者ID:ligoj,项目名称:plugin-prov,代码行数:32,代码来源:ImportCatalogResource.java

示例5: findAll

import org.ligoj.app.model.Node; //导入依赖的package包/类
/**
 * Return the nodes and their catalog status.
 * 
 * @return The nodes and their catalog status.
 */
@GET
@Path("catalog")
public List<CatalogVo> findAll() {
	// Get all catalogs
	final Map<String, ImportCatalogStatus> statuses = taskRepository.findAllVisible(securityHelper.getLogin()).stream()
			.collect(Collectors.toMap(s -> s.getLocked().getId(), Function.identity()));

	// Complete with nodes without populated catalog
	final Page<Node> providers = nodeRepository.findAllVisible(securityHelper.getLogin(), "", ProvResource.SERVICE_KEY, null, 1,
			PageRequest.of(0, 100));

	return providers.getContent().stream().sorted().map(NodeResource::toVo)
			.map(n -> new CatalogVo(Optional.ofNullable(statuses.get(n.getId())).orElseGet(() -> {
				// Create a mock catalog status
				final ImportCatalogStatus status = new ImportCatalogStatus();
				updateStats(status, n.getId());
				return status;
			}), n, locator.getResource(n.getId(), ImportCatalogService.class) != null, (int) repository.countByNode(n.getId())))
			.collect(Collectors.toList());
}
 
开发者ID:ligoj,项目名称:plugin-prov,代码行数:26,代码来源:ImportCatalogResource.java

示例6: create

import org.ligoj.app.model.Node; //导入依赖的package包/类
@Override
public void create(final int subscription) throws Exception {
	// Add an empty quote
	final ProvQuote quote = new ProvQuote();
	quote.setSubscription(subscriptionRepository.findOne(subscription));

	// Associate a default name and description
	quote.setName(quote.getSubscription().getProject().getName());
	final Node provider = quote.getSubscription().getNode().getRefined();
	final List<ProvLocation> locations = locationRepository.findAllBy("node.id", provider.getId());
	if (locations.isEmpty()) {
		// No available location, need a catalog to continue
		throw new BusinessException(SERVICE_KEY + "-no-catalog", provider.getId(), provider.getName());
	}
	quote.setLocation(locations.get(0));
	quote.setDescription(quote.getSubscription().getProject().getPkey() + "-> " + provider.getName());
	repository.saveAndFlush(quote);
}
 
开发者ID:ligoj,项目名称:plugin-prov,代码行数:19,代码来源:ProvResource.java

示例7: install

import org.ligoj.app.model.Node; //导入依赖的package包/类
/**
 * Install or update prices.
 */
public void install() throws IOException, URISyntaxException {
	// Node is already persisted, install EC2 prices
	final Node node = nodeRepository.findOneExpected(ProvAwsPluginResource.KEY);

	// The previously installed location cache. Key is the location AWS name
	final Map<String, ProvLocation> regions = locationRepository.findAllBy("node.id", node.getId()).stream()
			.collect(Collectors.toMap(INamableBean::getName, Function.identity()));

	// Update the workload : nb.regions + 3 (spot, EBS, S3, EFS)
	nextStep(node, null, 0);

	// Proceed to the install
	installStoragePrices(node, regions);
	installComputePrices(node, regions);

	// EFS need to be processed after EC2 for region mapping
	installEfsPrices(node, regions);
}
 
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:22,代码来源:ProvAwsPriceImportResource.java

示例8: newInstancePriceTerm

import org.ligoj.app.model.Node; //导入依赖的package包/类
/**
 * Build a new instance price type from the CSV line.
 */
private ProvInstancePriceTerm newInstancePriceTerm(final AwsEc2Price csvPrice, final Node node) {
	final ProvInstancePriceTerm result = new ProvInstancePriceTerm();
	result.setNode(node);
	result.setCode(csvPrice.getOfferTermCode());

	// Build the name from the leasing, purchase option and offering class
	result.setName(Arrays
			.stream(new String[] { csvPrice.getTermType(), csvPrice.getLeaseContractLength(),
					StringUtils.trimToNull(StringUtils.remove(csvPrice.getPurchaseOption(), "No Upfront")),
					StringUtils.trimToNull(StringUtils.remove(csvPrice.getOfferingClass(), "standard")) })
			.filter(Objects::nonNull).collect(Collectors.joining(", ")));

	// By default, hourly period
	result.setPeriod(60);

	// Handle leasing
	final Matcher matcher = LEASING_TIME.matcher(StringUtils.defaultIfBlank(csvPrice.getLeaseContractLength(), ""));
	if (matcher.find()) {
		// Convert years to minutes
		result.setPeriod(Integer.parseInt(matcher.group(1)) * 60 * 24 * 365);
	}
	iptRepository.saveAndFlush(result);
	return result;
}
 
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:28,代码来源:ProvAwsPriceImportResource.java

示例9: prepareData

import org.ligoj.app.model.Node; //导入依赖的package包/类
@Before
public void prepareData() throws IOException {
	persistSystemEntities();
	persistEntities("csv",
			new Class[] { Node.class, Project.class, CacheCompany.class, CacheUser.class, DelegateNode.class, Parameter.class,
					ProvLocation.class, ProvStorageType.class, Subscription.class, ParameterValue.class, ProvQuote.class },
			StandardCharsets.UTF_8.name());
	this.subscription = getSubscription("gStack");

	// Disable inner transaction
	this.resource = new ProvAwsPriceImportResource();
	applicationContext.getAutowireCapableBeanFactory().autowireBean(resource);
	this.resource.initSpotToNewRegion();
	this.resource.initEbsToApi();
	this.resource.importCatalogResource = new ImportCatalogResource();
	applicationContext.getAutowireCapableBeanFactory().autowireBean(this.resource.importCatalogResource);
	initSpringSecurityContext(DEFAULT_USER);
	resetImportTask();
}
 
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:20,代码来源:ProvAwsPriceImportResourceTest.java

示例10: prepareData

import org.ligoj.app.model.Node; //导入依赖的package包/类
@Before
public void prepareData() throws IOException {
	persistEntities(
			"csv", new Class[] { DelegateOrg.class, ContainerScope.class, CacheCompany.class, CacheUser.class, CacheGroup.class,
					CacheMembership.class, Project.class, Node.class, Parameter.class, Subscription.class, ParameterValue.class, 
					CacheProjectGroup.class },
			StandardCharsets.UTF_8.name());
	CacheManager.getInstance().getCache("container-scopes").removeAll();

	// Only with Spring context
	this.subscription = getSubscription("gStack", IdentityResource.SERVICE_KEY);

	// Coverage only
	resource.getKey();
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:16,代码来源:LdapPluginResourceTest.java

示例11: addSubscriptionActivitiesDuplicateNode

import org.ligoj.app.model.Node; //导入依赖的package包/类
@Test
public void addSubscriptionActivitiesDuplicateNode() throws Exception {
	final Map<String, Map<String, Activity>> activities = new HashMap<>();
	final LdapPluginResource resource = new LdapPluginResource();
	final Subscription susbscription = new Subscription();
	final Node service = new Node();
	service.setId("J");
	susbscription.setNode(service);
	final SampleActivityProvider plugin = Mockito.mock(SampleActivityProvider.class);
	final Set<INamableBean<String>> nodes = new HashSet<>();
	nodes.add(service);
	resource.addSubscriptionActivities(activities, null, susbscription, plugin, nodes);
	Assert.assertTrue(activities.isEmpty());
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:15,代码来源:LdapPluginResourceTest.java

示例12: acceptNotMatch

import org.ligoj.app.model.Node; //导入依赖的package包/类
@Test
public void acceptNotMatch() {
	final Node ldap = new Node();
	ldap.setId("service:id:ldap:test");
	ldap.setRefined(nodeRepository.findOneExpected("service:id:ldap"));
	ldap.setName("LDAP Test");
	nodeRepository.saveAndFlush(ldap);
	final ParameterValue parameterValue = new ParameterValue();
	parameterValue.setNode(ldap);
	parameterValue.setParameter(parameterRepository.findOneExpected("service:id:uid-pattern"));
	parameterValue.setData("-nomatch-");
	em.persist(parameterValue);
	Assert.assertFalse(resource.accept(new UsernamePasswordAuthenticationToken("some", ""), "service:id:ldap:test"));
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:15,代码来源:LdapPluginResourceTest.java

示例13: accept

import org.ligoj.app.model.Node; //导入依赖的package包/类
@Test
public void accept() {
	final Node ldap = new Node();
	ldap.setId("service:id:ldap:test");
	ldap.setRefined(nodeRepository.findOneExpected("service:id:ldap"));
	ldap.setName("LDAP Test");
	nodeRepository.saveAndFlush(ldap);
	persistParameter(ldap, IdentityResource.PARAMETER_UID_PATTERN, "some-.*-text");
	Assert.assertTrue(resource.accept(new UsernamePasswordAuthenticationToken("some-awesome-text", ""), "service:id:ldap:test"));
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:11,代码来源:LdapPluginResourceTest.java

示例14: persistParameter

import org.ligoj.app.model.Node; //导入依赖的package包/类
private void persistParameter(final Node node, final String id, final String value) {
	final ParameterValue parameterValue = new ParameterValue();
	parameterValue.setNode(node);
	parameterValue.setParameter(parameterRepository.findOneExpected(id));
	parameterValue.setData(value);
	em.persist(parameterValue);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:8,代码来源:LdapPluginResourceTest.java

示例15: prepareSubscription

import org.ligoj.app.model.Node; //导入依赖的package包/类
@Before
public void prepareSubscription() throws IOException {
	persistSystemEntities();
	persistEntities("csv", new Class[] { Calendar.class, Holiday.class, Node.class, Project.class,
			Subscription.class, BugTrackerConfiguration.class, BusinessHours.class, Sla.class },
			StandardCharsets.UTF_8.name());
	this.subscription = getSubscription("MDA");
}
 
开发者ID:ligoj,项目名称:plugin-bt,代码行数:9,代码来源:BugTrackerResourceTest.java


注:本文中的org.ligoj.app.model.Node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。