Search in sources :

Example 96 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netconf by opendaylight.

the class CreateStreamUtil method createDataChangeNotifiStream.

/**
 * Create data-change-event or notification stream with POST operation via RPC.
 *
 * @param payload      Input of RPC - example in JSON (data-change-event stream):
 *                     <pre>
 *                     {@code
 *                         {
 *                             "input": {
 *                                 "path": "/toaster:toaster/toaster:toasterStatus",
 *                                 "sal-remote-augment:datastore": "OPERATIONAL",
 *                                 "sal-remote-augment:scope": "ONE"
 *                             }
 *                         }
 *                     }
 *                     </pre>
 * @param refSchemaCtx Reference to {@link EffectiveModelContext}.
 * @return {@link DOMRpcResult} - Output of RPC - example in JSON:
 *     <pre>
 *     {@code
 *         {
 *             "output": {
 *                 "stream-name": "toaster:toaster/toaster:toasterStatus/datastore=OPERATIONAL/scope=ONE"
 *             }
 *         }
 *     }
 *     </pre>
 */
static DOMRpcResult createDataChangeNotifiStream(final NormalizedNodePayload payload, final EffectiveModelContext refSchemaCtx) {
    // parsing out of container with settings and path
    final ContainerNode data = (ContainerNode) requireNonNull(payload).getData();
    final QName qname = payload.getInstanceIdentifierContext().getSchemaNode().getQName();
    final YangInstanceIdentifier path = preparePath(data, qname);
    // building of stream name
    final StringBuilder streamNameBuilder = new StringBuilder(prepareDataChangeNotifiStreamName(path, requireNonNull(refSchemaCtx), data));
    final NotificationOutputType outputType = prepareOutputType(data);
    if (outputType.equals(NotificationOutputType.JSON)) {
        streamNameBuilder.append('/').append(outputType.getName());
    }
    final String streamName = streamNameBuilder.toString();
    // registration of the listener
    ListenersBroker.getInstance().registerDataChangeListener(path, streamName, outputType);
    // building of output
    final QName outputQname = QName.create(qname, "output");
    final QName streamNameQname = QName.create(qname, "stream-name");
    final ContainerNode output = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(outputQname)).withChild(ImmutableNodes.leafNode(streamNameQname, streamName)).build();
    return new DefaultDOMRpcResult(output);
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) QName(org.opendaylight.yangtools.yang.common.QName) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NotificationOutputType(org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 97 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_12_R1 method openPage.

@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    String title = inventory.getTitle();
    Container container = createContainer(entityPlayer.inventory, entityPlayer, inventory);
    container.windowId = entityPlayer.nextContainerCounter();
    TileEntityWildChest tileEntityWildChest = getTileEntity(inventory.getOwner());
    entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, tileEntityWildChest.getContainerName(), new ChatComponentText(title), inventory.getSize()));
    entityPlayer.activeContainer = container;
    entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
Also used : Container(net.minecraft.server.v1_12_R1.Container) TileEntityContainer(com.bgsoftware.wildchests.objects.containers.TileEntityContainer) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) PacketPlayOutOpenWindow(net.minecraft.server.v1_12_R1.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.server.v1_12_R1.ChatComponentText)

Example 98 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_8_R3 method openPage.

@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    String title = inventory.getTitle();
    Container container = createContainer(entityPlayer.inventory, entityPlayer, inventory);
    container.windowId = entityPlayer.nextContainerCounter();
    TileEntityWildChest tileEntityWildChest = getTileEntity(inventory.getOwner());
    entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, tileEntityWildChest.getContainerName(), new ChatComponentText(title), inventory.getSize()));
    entityPlayer.activeContainer = container;
    entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
Also used : TileEntityContainer(com.bgsoftware.wildchests.objects.containers.TileEntityContainer) Container(net.minecraft.server.v1_8_R3.Container) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) PacketPlayOutOpenWindow(net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.server.v1_8_R3.ChatComponentText)

Example 99 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project mdsal by opendaylight.

the class Mdsal298Test method testUnkeyedDataTreeModification.

@Test
public void testUnkeyedDataTreeModification() throws InterruptedException, ExecutionException {
    final DataTreeChangeListener<Container> listener = assertWrittenContainer(Container.QNAME, Container.class, new ContainerBuilder().build());
    final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
    domTx.put(CONFIGURATION, YangInstanceIdentifier.create(CONTAINER_NID).node(Unkeyed.QNAME), Builders.unkeyedListBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).addChild(ImmutableNodes.leafNode(FOO_QNAME, "foo")).build()).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).addChild(ImmutableNodes.leafNode(FOO_QNAME, "bar")).build()).build());
    domTx.commit().get();
    final ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
    verify(listener).onDataTreeChanged(captor.capture());
    Collection<DataTreeModification<Container>> capture = captor.getValue();
    assertEquals(1, capture.size());
    final DataTreeModification<Container> change = capture.iterator().next();
    assertEquals(CONTAINER_TID, change.getRootPath());
    final DataObjectModification<Container> changedContainer = change.getRootNode();
    assertEquals(Item.of(Container.class), changedContainer.getIdentifier());
    assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
    final Container containerAfter = changedContainer.getDataAfter();
    assertEquals(new ContainerBuilder().setUnkeyed(List.of(new UnkeyedBuilder().setFoo("foo").build(), new UnkeyedBuilder().setFoo("bar").build())).build(), containerAfter);
    final Collection<? extends DataObjectModification<?>> changedChildren = changedContainer.getModifiedChildren();
    assertEquals(0, changedChildren.size());
}
Also used : DataTreeModification(org.opendaylight.mdsal.binding.api.DataTreeModification) UnkeyedBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.UnkeyedBuilder) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) Container(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container) ContainerBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.ContainerBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) Collection(java.util.Collection) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest) Test(org.junit.Test)

Example 100 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project mdsal by opendaylight.

the class TestListSquashing method testEmptyUserOrderedList.

@Test
public void testEmptyUserOrderedList() {
    final Container cont = new ContainerBuilder().setKeyed(List.of()).setUnkeyed(List.of()).build();
    // Empty Lists should become null
    assertNull(cont.getKeyed());
    assertNull(cont.getUnkeyed());
}
Also used : Container(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container) ContainerBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.ContainerBuilder) Test(org.junit.Test)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)45 Test (org.junit.Test)16 HashMap (java.util.HashMap)10 Container (net.minecraft.server.v1_12_R1.Container)9 Container (net.minecraft.server.v1_16_R3.Container)9 Container (org.flyte.api.v1.Container)9 FailedNbt (com.ruinscraft.panilla.api.exception.FailedNbt)8 INbtTagCompound (com.ruinscraft.panilla.api.nbt.INbtTagCompound)8 Container (net.minecraft.server.v1_11_R1.Container)8 Container (net.minecraft.server.v1_14_R1.Container)8 Container (net.minecraft.server.v1_15_R1.Container)8 Container (net.minecraft.server.v1_16_R1.Container)8 Container (net.minecraft.server.v1_16_R2.Container)8 Container (net.minecraft.server.v1_8_R3.Container)8 ByteBuf (io.netty.buffer.ByteBuf)7 ArrayList (java.util.ArrayList)7 Container (net.minecraft.server.v1_13_R1.Container)7 Container (net.minecraft.server.v1_13_R2.Container)6 Container (net.minecraft.server.v1_10_R1.Container)5 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)5