コード例 #1
0
 private Object convertValue(
     final ClassAttributeAssignmentModel assignment, final String stringValue) {
   final String typeCode = assignment.getAttributeType().getCode();
   if (ClassificationAttributeTypeEnum.BOOLEAN.getCode().equals(typeCode)) {
     return Boolean.valueOf(stringValue);
   } else if (ClassificationAttributeTypeEnum.ENUM.getCode().equals(typeCode)) {
     // YTODO
     final Item item = JaloSession.getCurrentSession().getItem(PK.parse(stringValue));
     final Object value = load(item);
     validateParameterNotNull(value, "No such value with PK: " + stringValue);
     return value;
   } else if (ClassificationAttributeTypeEnum.NUMBER.getCode().equals(typeCode)) {
     return Double.valueOf(stringValue);
   } else if (ClassificationAttributeTypeEnum.STRING.getCode().equals(typeCode)) {
     return stringValue;
   } else if (ClassificationAttributeTypeEnum.DATE.getCode().equals(typeCode)) {
     try {
       return Utilities.getDateTimeInstance().parse(stringValue);
     } catch (final ParseException e) {
       throw new IllegalArgumentException(e.getMessage(), e);
     }
   } else {
     throw new IllegalArgumentException("Invalid classifcation attribute type code: " + typeCode);
   }
 }
 private void runAsReader() {
   final long mediaPK = media.getPk().getLongValue();
   long globalPK = 0;
   while (!Thread.currentThread().isInterrupted()) {
     final MediaModel ctx = modelService.get(PK.fromLong(mediaPK));
     modelService.refresh(ctx);
     globalPK |= ctx.getPk().getLongValue();
   }
   assertEquals(mediaPK, globalPK);
 }
コード例 #3
0
 @Override
 public void run() {
   Registry.setCurrentTenant(Registry.getTenantByID(tenant));
   try {
     final ConsignmentModel model = getModelService().get(PK.fromLong(consignment));
     getWarehouse2ProcessAdapter()
         .receiveConsignmentStatus(model, WarehouseConsignmentStatus.COMPLETE);
   } finally {
     Registry.unsetCurrentTenant();
   }
 }
コード例 #4
0
  @Override
  public void handleEvent(
      final UICockpitPerspective perspective, final Map<String, String[]> params) {
    final String itemParam = this.getParameter(params, COMPETITION_KEY);

    CompetitionModel competition = null;
    try {
      final TypedObject item =
          UISessionUtils.getCurrentSession().getTypeService().wrapItem(PK.parse(itemParam));
      if (item != null) {
        competition = (CompetitionModel) item.getObject();
      }
    } catch (final Exception e) {
      LOG.warn("competition specified in jumpin URL not forund: " + itemParam, e);
    }

    if (competition != null) {
      getFrontendController().changeCompetition(competition.getCode());
    }
  }
コード例 #5
0
  /** Creates some attachments and assigns them to the test workflow. */
  @Test
  public void testAttachments() {
    final PK workflowPk = testWorkflow.getPK();
    // create product attachment
    final Product product = jaloSession.getProductManager().createProduct("sabbers");
    assertNotNull("Product not null", product);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(WorkflowItemAttachment.CODE, "productTest");
    map.put(WorkflowItemAttachment.ITEM, product);
    map.put(WorkflowItemAttachment.WORKFLOW, testWorkflow);
    final WorkflowItemAttachment attachProduct =
        WorkflowManager.getInstance().createWorkflowItemAttachment(map);
    assertNotNull("Attachment not null", attachProduct);

    // create category attachment
    final Category category =
        CategoryManager.getInstance().createCategory(PK.createUUIDPK(0).getHex());
    assertNotNull("Category not null", category);
    map = new HashMap<String, Object>();
    map.put(WorkflowItemAttachment.CODE, "categoryTest");
    map.put(WorkflowItemAttachment.ITEM, category);
    map.put(WorkflowItemAttachment.WORKFLOW, testWorkflow);
    final WorkflowItemAttachment attachCategory =
        WorkflowManager.getInstance().createWorkflowItemAttachment(map);
    assertNotNull("Attachment not null", attachCategory);

    final WorkflowAction action1 = getAction(ACTIONCODES.ACTION1.name());
    action1.setAttachments(
        Arrays.asList(new WorkflowItemAttachment[] {attachProduct, attachCategory}));

    // restart
    Registry.getCurrentTenant().getCache();

    // check attachments
    final Workflow found = JaloSession.getCurrentSession().getItem(workflowPk);
    assertEquals("Excpected number of attachments", 2, found.getAttachments().size());
    final WorkflowAction foundAction = getAction(ACTIONCODES.ACTION1.name());
    assertEquals(
        "Excpected number of attachments of action 1", 2, foundAction.getAttachments().size());
  }
 /**
  * Gets the {@link CsTicketChangeEventStringEntryModel} resource which is addressed by current
  * resource request.
  *
  * @see de.hybris.platform.webservices.AbstractYResource#readResource(String)
  */
 @Override
 protected CsTicketChangeEventStringEntryModel readResource(final String resourceId)
     throws Exception {
   return serviceLocator.getModelService().get(PK.parse(resourceId));
 }
コード例 #7
0
 /**
  * Gets the {@link AbstractPromotionModel} resource which is addressed by current resource
  * request.
  *
  * @see de.hybris.platform.webservices.AbstractYResource#readResource(String)
  */
 @Override
 protected AbstractPromotionModel readResource(final String resourceId) throws Exception {
   return serviceLocator.getModelService().get(PK.parse(resourceId));
 }
コード例 #8
0
  @Test
  public void testGetAttributesForModiferCriteria() {
    final AttributeDescriptorModel declaredDescriptor = mock(AttributeDescriptorModel.class);
    when(declaredDescriptor.getModifiers()).thenReturn(Integer.valueOf(AttributeModifiers.READ));

    final AttributeDescriptorModel privateDescriptor = mock(AttributeDescriptorModel.class);
    when(privateDescriptor.getModifiers())
        .thenReturn(Integer.valueOf(AttributeModifiers.READ | AttributeModifiers.PRIVATE));
    when(privateDescriptor.getPrivate()).thenReturn(Boolean.TRUE);

    final AttributeDescriptorModel inheritedDescriptor = mock(AttributeDescriptorModel.class);
    when(inheritedDescriptor.getModifiers())
        .thenReturn(Integer.valueOf(AttributeModifiers.READ | AttributeModifiers.INHERITED));

    final AttributeDescriptorModel writableDescriptor = mock(AttributeDescriptorModel.class);
    when(writableDescriptor.getModifiers())
        .thenReturn(Integer.valueOf(AttributeModifiers.READ | AttributeModifiers.WRITE));
    when(writableDescriptor.getWritable()).thenReturn(Boolean.TRUE);

    final AttributeDescriptorModel partofDescriptor = mock(AttributeDescriptorModel.class);
    when(partofDescriptor.getModifiers())
        .thenReturn(
            Integer.valueOf(
                AttributeModifiers.READ | AttributeModifiers.PARTOF | AttributeModifiers.WRITE));
    when(partofDescriptor.getWritable()).thenReturn(Boolean.TRUE);
    when(partofDescriptor.getPartOf()).thenReturn(Boolean.TRUE);

    final Set<AttributeDescriptorModel> declaredDescriptorModels =
        new HashSet<AttributeDescriptorModel>();
    declaredDescriptorModels.add(declaredDescriptor);
    declaredDescriptorModels.add(writableDescriptor);
    declaredDescriptorModels.add(partofDescriptor);

    final Set<AttributeDescriptorModel> inheritedDescriptorModels =
        new HashSet<AttributeDescriptorModel>();
    inheritedDescriptorModels.add(inheritedDescriptor);

    final ComposedTypeModel typeModel = mock(ComposedTypeModel.class);
    when((typeModel).getDeclaredattributedescriptors()).thenReturn(declaredDescriptorModels);
    when((typeModel).getInheritedattributedescriptors()).thenReturn(inheritedDescriptorModels);

    final PK descriptorPk = PK.fromLong(1234567890);
    final AttributeDescriptor privateDescriptorItem = mock(AttributeDescriptor.class);
    when(privateDescriptorItem.getPK()).thenReturn(descriptorPk);
    when(Boolean.valueOf(privateDescriptorItem.isPrivate())).thenReturn(Boolean.TRUE);

    final Set<AttributeDescriptor> privateDescriptorItems = new HashSet<AttributeDescriptor>();
    privateDescriptorItems.add(privateDescriptorItem);

    final ComposedType composedType = mock(ComposedType.class);
    when(modelService.getSource(typeModel)).thenReturn(composedType);
    when(composedType.getAttributeDescriptorsIncludingPrivate()).thenReturn(privateDescriptorItems);
    when(modelService.get(privateDescriptorItem)).thenReturn(privateDescriptor);

    when(typeDao.findComposedTypeByCode("modifierTest")).thenReturn(typeModel);

    final AttributeModifierCriteria modifierCriteria =
        new AttributeModifierCriteria(0, AttributeModifiers.ALL, 0);
    Assert.assertEquals(
        "Five declared descriptors expected",
        5,
        typeService.getAttributesForModifiers("modifierTest", modifierCriteria).size());

    modifierCriteria.addDisallowed(AttributeModifiers.PRIVATE);
    Assert.assertEquals(
        "Four declared descriptors expected",
        4,
        typeService.getAttributesForModifiers("modifierTest", modifierCriteria).size());

    modifierCriteria.addDisallowed(AttributeModifiers.INHERITED);
    Assert.assertEquals(
        "Three declared descriptors expected",
        3,
        typeService.getAttributesForModifiers("modifierTest", modifierCriteria).size());

    modifierCriteria.addRequired(AttributeModifiers.WRITE);
    Assert.assertEquals(
        "Two declared descriptors expected",
        2,
        typeService.getAttributesForModifiers("modifierTest", modifierCriteria).size());

    modifierCriteria.addRequired(AttributeModifiers.PARTOF);
    Assert.assertEquals(
        "One declared descriptor expected",
        1,
        typeService.getAttributesForModifiers("modifierTest", modifierCriteria).size());
  }
 /**
  * Gets the {@link PromotionOrderChangeDeliveryModeActionModel} resource which is addressed by
  * current resource request.
  *
  * @see de.hybris.platform.webservices.AbstractYResource#readResource(String)
  */
 @Override
 protected PromotionOrderChangeDeliveryModeActionModel readResource(final String resourceId)
     throws Exception {
   return serviceLocator.getModelService().get(PK.parse(resourceId));
 }