/** * Ctor. * * @param typeName is the event type name * @param eventType is the event type of the wrapped events * @param properties is the additional properties this wrapper adds * @param metadata event type metadata * @param eventAdapterService is the service for resolving unknown wrapped types */ public WrapperEventType( EventTypeMetadata metadata, String typeName, int eventTypeId, EventType eventType, Map<String, Object> properties, EventAdapterService eventAdapterService) { checkForRepeatedPropertyNames(eventType, properties); this.metadata = metadata; this.underlyingEventType = eventType; EventTypeMetadata metadataMapType = EventTypeMetadata.createAnonymous(typeName); this.underlyingMapType = new MapEventType( metadataMapType, typeName, 0, eventAdapterService, properties, null, null, null); this.isNoMapProperties = properties.isEmpty(); this.eventAdapterService = eventAdapterService; this.eventTypeId = eventTypeId; propertyGetterCache = new HashMap<String, EventPropertyGetter>(); updatePropertySet(); if (metadata.getTypeClass() == EventTypeMetadata.TypeClass.NAMED_WINDOW) { startTimestampPropertyName = eventType.getStartTimestampPropertyName(); endTimestampPropertyName = eventType.getEndTimestampPropertyName(); EventTypeUtility.validateTimestampProperties( this, startTimestampPropertyName, endTimestampPropertyName); } }
public void testJoinSelect() { String eventA = SupportBean.class.getName(); String eventB = SupportBean.class.getName(); String joinStatement = "select s0.doubleBoxed, s1.intPrimitive*s1.intBoxed/2.0 as div from " + eventA + "(theString='s0').win:length(3) as s0," + eventB + "(theString='s1').win:length(3) as s1" + " where s0.doubleBoxed = s1.doubleBoxed"; EPStatement joinView = epService.getEPAdministrator().createEPL(joinStatement); joinView.addListener(updateListener); EventType result = joinView.getEventType(); assertEquals(Double.class, result.getPropertyType("s0.doubleBoxed")); assertEquals(Double.class, result.getPropertyType("div")); assertEquals(2, joinView.getEventType().getPropertyNames().length); assertNull(updateListener.getLastNewData()); sendEvent("s0", 1, 4, 5); sendEvent("s1", 1, 3, 2); EventBean[] newEvents = updateListener.getLastNewData(); assertEquals(1d, newEvents[0].get("s0.doubleBoxed")); assertEquals(3d, newEvents[0].get("div")); Iterator<EventBean> iterator = joinView.iterator(); EventBean theEvent = iterator.next(); assertEquals(1d, theEvent.get("s0.doubleBoxed")); assertEquals(3d, theEvent.get("div")); }
/** * Update the recalibration statistics using the information in recalInfo * * @param recalInfo data structure holding information about the recalibration values for a single * read */ @Requires("recalInfo != null") public void updateDataForRead(final ReadRecalibrationInfo recalInfo) { final GATKSAMRecord read = recalInfo.getRead(); final ReadCovariates readCovariates = recalInfo.getCovariatesValues(); final RecalibrationTables tables = getUpdatableRecalibrationTables(); final NestedIntegerArray<RecalDatum> qualityScoreTable = tables.getQualityScoreTable(); for (int offset = 0; offset < read.getReadBases().length; offset++) { if (!recalInfo.skip(offset)) { for (final EventType eventType : EventType.values()) { final int[] keys = readCovariates.getKeySet(offset, eventType); final int eventIndex = eventType.ordinal(); final byte qual = recalInfo.getQual(eventType, offset); final double isError = recalInfo.getErrorFraction(eventType, offset); RecalUtils.incrementDatumOrPutIfNecessary( qualityScoreTable, qual, isError, keys[0], keys[1], eventIndex); for (int i = 2; i < covariates.length; i++) { if (keys[i] < 0) continue; RecalUtils.incrementDatumOrPutIfNecessary( tables.getTable(i), qual, isError, keys[0], keys[1], keys[i], eventIndex); } } } } }
public Class getPropertyType(String property) { if (underlyingEventType.isProperty(property)) { return underlyingEventType.getPropertyType(property); } else if (underlyingMapType.isProperty(property)) { return underlyingMapType.getPropertyType(property); } else { return null; } }
private void initTargetCall( int aTargetCallNo, Class<?> aCallClass, Class<?> aOutClass, Class<?> aEventClass) { EventType eventKey = EventTypesFactory.get().toType(aEventClass); int eventIndex = eventKey.ordinal(); List<CallType> callTargets = mEvents.get(eventIndex); // CallType callTarget = CallTypesFactory.get().toType(aCallClass); callTargets.add(callTarget); }
/** * used to print the queue content * * @return */ public String getPrintableString() { StringBuilder res = new StringBuilder(); for (EventType e : this.queue) { res.append(e.toString()); } return res.toString(); }
public static EventType parse(String value) { EventType[] v = EventType.values(); for (EventType val : v) { if (val.toString().equals(value)) { return val; } } return null; }
public void testSchemaXMLWSchemaWithAll() throws Exception { Configuration config = SupportConfigFactory.getConfiguration(); ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.setRootElementName("event-page-visit"); String schemaUri = TestSchemaXMLEvent.class .getClassLoader() .getResource(CLASSLOADER_SCHEMA_WITH_ALL_URI) .toString(); eventTypeMeta.setSchemaResource(schemaUri); eventTypeMeta.addNamespacePrefix("ss", "samples:schemas:simpleSchemaWithAll"); eventTypeMeta.addXPathProperty("url", "/ss:event-page-visit/ss:url", XPathConstants.STRING); config.addEventType("PageVisitEvent", eventTypeMeta); epService = EPServiceProviderManager.getProvider("TestSchemaXML", config); epService.initialize(); updateListener = new SupportUpdateListener(); // url='page4' String text = "select a.url as sesja from pattern [ every a=PageVisitEvent(url='page1') ]"; EPStatement stmt = epService.getEPAdministrator().createEPL(text); stmt.addListener(updateListener); SupportXML.sendEvent( epService.getEPRuntime(), "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n" + "<url>page1</url>" + "</event-page-visit>"); EventBean theEvent = updateListener.getLastNewData()[0]; assertEquals("page1", theEvent.get("sesja")); updateListener.reset(); SupportXML.sendEvent( epService.getEPRuntime(), "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n" + "<url>page2</url>" + "</event-page-visit>"); assertFalse(updateListener.isInvoked()); EventType type = epService.getEPAdministrator().createEPL("select * from PageVisitEvent").getEventType(); EPAssertionUtil.assertEqualsAnyOrder( new Object[] { new EventPropertyDescriptor( "sessionId", Node.class, null, false, false, false, false, true), new EventPropertyDescriptor( "customerId", Node.class, null, false, false, false, false, true), new EventPropertyDescriptor("url", String.class, null, false, false, false, false, false), new EventPropertyDescriptor("method", Node.class, null, false, false, false, false, true), }, type.getPropertyDescriptors()); }
protected void onEvent(AjaxRequestTarget target) { Request request = RequestCycle.get().getRequest(); Overlay overlay = null; String markerParameter = request.getRequestParameters().getParameterValue("marker").toString(); if (markerParameter != null) { OpenLayersMap map = getOpenLayerMap(); for (Overlay ovl : map.getOverlays()) { if (ovl.getId().equals(markerParameter)) { overlay = ovl; break; } } } String markerEvent = request.getRequestParameters().getParameterValue("event").toString(); if (wantEvents) { // Translate from string to type! EventType eventType = EventType.valueOf(markerEvent); onEvent(target, overlay, eventType); } else { onClick(target, overlay); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Event<?> other = (Event<?>) obj; if (param == null) { if (other.param != null) { return false; } } else if (!param.equals(other.param)) { return false; } if (type == null) { if (other.type != null) { return false; } } else if (!type.equals(other.type)) { return false; } return true; }
/** Creates the entity by parsing the root node and all the children. */ public SinaContainer(JsonNode rootNode) throws JsonParseException, JsonMappingException, IOException { this.id = rootNode.get("id").longValue(); this.receivedAt = DateTimeFormat.forPattern(RECEIVED_DATETIME_PATTERN) .parseDateTime(rootNode.get("received_at").textValue()); JsonNode textNode = rootNode.get("text"); this.rawContents = rootNode.toString(); this.eventType = EventType.getByName(textNode.get("type").textValue()); this.event = textNode.get("event").toString(); // TODO: define what to do with DELETE messages this.matchInfoKeyword = rootNode.get("match_info") == null ? null : rootNode.get("match_info").get("keyword").textValue(); this.matchInfoUid = rootNode.get("match_info") == null ? null : rootNode.get("match_info").get("uid").longValue(); ObjectMapper mapper = SinaWeiboParser.getObjectMapper(); JsonParser parser; switch (eventType) { case COMMENT: parser = textNode.get("comment").traverse(mapper); this.contentNode = parser.readValueAs(SinaCommentNode.class); break; case STATUS: parser = textNode.get("status").traverse(mapper); this.contentNode = parser.readValueAs(SinaStatusNode.class); break; } }
public void testInsertFromPattern() { String stmtOneText = "insert into streamA select * from pattern [every " + SupportBean.class.getName() + "]"; SupportUpdateListener listenerOne = new SupportUpdateListener(); EPStatement stmtOne = epService.getEPAdministrator().createEPL(stmtOneText); stmtOne.addListener(listenerOne); String stmtTwoText = "insert into streamA select * from pattern [every " + SupportBean.class.getName() + "]"; SupportUpdateListener listenerTwo = new SupportUpdateListener(); EPStatement stmtTwo = epService.getEPAdministrator().createEPL(stmtTwoText); stmtTwo.addListener(listenerTwo); EventType eventType = stmtOne.getEventType(); assertEquals(Map.class, eventType.getUnderlyingType()); }
public EventPropertyGetterIndexed getGetterIndexed(String indexedProperty) { final EventPropertyGetterIndexed undIndexed = underlyingEventType.getGetterIndexed(indexedProperty); if (undIndexed != null) { return new EventPropertyGetterIndexed() { public Object get(EventBean theEvent, int index) throws PropertyAccessException { if (!(theEvent instanceof DecoratingEventBean)) { throw new PropertyAccessException("Mismatched property getter to EventBean type"); } DecoratingEventBean wrapperEvent = (DecoratingEventBean) theEvent; EventBean wrappedEvent = wrapperEvent.getUnderlyingEvent(); if (wrappedEvent == null) { return null; } return undIndexed.get(wrappedEvent, index); } }; } final EventPropertyGetterIndexed decoIndexed = underlyingMapType.getGetterIndexed(indexedProperty); if (decoIndexed != null) { return new EventPropertyGetterIndexed() { public Object get(EventBean theEvent, int index) throws PropertyAccessException { if (!(theEvent instanceof DecoratingEventBean)) { throw new PropertyAccessException("Mismatched property getter to EventBean type"); } DecoratingEventBean wrapperEvent = (DecoratingEventBean) theEvent; Map map = wrapperEvent.getDecoratingProperties(); return decoIndexed.get( eventAdapterService.adapterForTypedMap(map, underlyingMapType), index); } }; } return null; }
public FragmentEventType getFragmentType(String property) { FragmentEventType fragment = underlyingEventType.getFragmentType(property); if (fragment != null) { return fragment; } return underlyingMapType.getFragmentType(property); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((param == null) ? 0 : param.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); return result; }
/** * @param EventType eventType тип события * @param AbstractUser user пользователь, к которому будет прикреплено это событие * @param Object[] o массив объектов, необходимых для формирования события. типы объектов указаны * в описании типа события * @see EventType */ public void save(EventType eventType, AbstractUser user, Object... o) { Assert.notNull(eventType); EventItem item = eventType.fillEventItem(user, o); if (item != null) { item.setEventType(eventType); journalDao.saveEventItem(item); } }
public void testConfiguredViaPropsAndXML() { Configuration configuration = SupportConfigFactory.getConfiguration(); configuration .getEngineDefaults() .getEventMeta() .setDefaultEventRepresentation(Configuration.EventRepresentation.OBJECTARRAY); configuration.addEventType( "MyOAType", "bean,theString,map".split(","), new Object[] {SupportBean.class.getName(), "string", "java.util.Map"}); EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration); epService.initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.startTest(epService, this.getClass(), getName()); } EventType eventType = epService.getEPAdministrator().getConfiguration().getEventType("MyOAType"); assertEquals(Object[].class, eventType.getUnderlyingType()); assertEquals(String.class, eventType.getPropertyType("theString")); assertEquals(Map.class, eventType.getPropertyType("map")); assertEquals(SupportBean.class, eventType.getPropertyType("bean")); EPStatement stmt = epService .getEPAdministrator() .createEPL("select bean, theString, map('key'), bean.theString from MyOAType"); SupportUpdateListener listener = new SupportUpdateListener(); stmt.addListener(listener); assertEquals(Object[].class, stmt.getEventType().getUnderlyingType()); SupportBean bean = new SupportBean("E1", 1); epService .getEPRuntime() .sendEvent( new Object[] {bean, "abc", Collections.singletonMap("key", "value")}, "MyOAType"); EPAssertionUtil.assertProps( listener.assertOneGetNew(), "bean,theString,map('key'),bean.theString".split(","), new Object[] {bean, "abc", "value", "E1"}); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.endTest(); } }
private void updatePropertySet() { PropertyDescriptorComposite compositeProperties = getCompositeProperties(underlyingEventType, underlyingMapType); propertyNames = compositeProperties.getPropertyNames(); propertyDescriptorMap = compositeProperties.getPropertyDescriptorMap(); propertyDesc = compositeProperties.getDescriptors(); numPropertiesUnderlyingType = underlyingEventType.getPropertyDescriptors().length; }
public static String asString(NamespaceNotification n) { return "[Notification: " + EventType.fromByteValue(n.type).name() + " " + n.path + " " + n.txId + "]"; }
@Override public void onPlaybackEvent(EventType eventType, PlayerState playerState) { Log.d("MainActivity", "Playback event received: " + eventType.name()); switch (eventType) { // Handle event type as necessary default: break; } }
public static String getAdditionalPath(NamespaceNotification notification) { switch (EventType.fromByteValue(notification.getType())) { case FILE_ADDED: return notification.path.substring( notification.path.lastIndexOf('/') + 1, notification.path.length()); default: return null; } }
public Class getUnderlyingType() { // If the additional properties are empty, such as when wrapping a native event by means of // wildcard-only select // then the underlying type is simply the wrapped type. if (isNoMapProperties) { return underlyingEventType.getUnderlyingType(); } else { return Pair.class; } }
@Override public void onPlaybackEvent(final EventType eventType, final PlayerState playerState) { // Remember kids, always use the English locale when changing case for non-UI strings! // Otherwise you'll end up with mysterious errors when running in the Turkish locale. // See: http://java.sys-con.com/node/46241 String eventName = eventType.name().toLowerCase(Locale.ENGLISH).replaceAll("_", " "); logStatus("Player event: " + eventName); mCurrentPlayerState = playerState; updateButtons(); }
private void checkForRepeatedPropertyNames(EventType eventType, Map<String, Object> properties) { for (String property : eventType.getPropertyNames()) { if (properties.keySet().contains(property)) { throw new EPException( "Property " + property + " occurs in both the underlying event and in the additional properties"); } } }
@Override public int hashCode() { final int prime = 31; int result = 1; // result = prime * result + ((eventSource == null) ? 0 : eventSource.hashCode()); result = prime * result + ((eventType == null) ? 0 : eventType.hashCode()); result = prime * result + (sent ? 1231 : 1237); result = prime * result + sequence; // dont use this ? // result = prime * result + (int) (timestamp ^ (timestamp >>> 32)); return result; }
public PostingRule findPostingRuleByEventTypeAndDate(EventType eventType, DateTime when) { final PostingRule postingRule = getPostingRuleByEventTypeAndDate(eventType, when); if (postingRule == null) { throw new DomainException( "error.accounting.agreement.ServiceAgreementTemplate.cannot.find.postingRule.for.eventType.and.date.desc", when.toDateTime().toString("dd-MM-yyyy HH:mm"), getEnumerationResourcesString(eventType.getQualifiedName())); } return postingRule; }
public EventTargets() { final int EVENTS_COUNT = EventType.values().length; mEvents = new ArrayList<>(EVENTS_COUNT); for (int i = 0; i < EVENTS_COUNT; i++) { mEvents.add(new ArrayList<CallType>(1)); } // initTargetCalls(); // for (int i = 0; i < EVENTS_COUNT; i++) { mEvents.set(i, Collections.unmodifiableList(mEvents.get(i))); } }
private static PropertyDescriptorComposite getCompositeProperties( EventType underlyingEventType, MapEventType underlyingMapType) { List<String> propertyNames = new ArrayList<String>(); propertyNames.addAll(Arrays.asList(underlyingEventType.getPropertyNames())); propertyNames.addAll(Arrays.asList(underlyingMapType.getPropertyNames())); String[] propertyNamesArr = propertyNames.toArray(new String[propertyNames.size()]); List<EventPropertyDescriptor> propertyDesc = new ArrayList<EventPropertyDescriptor>(); HashMap<String, EventPropertyDescriptor> propertyDescriptorMap = new HashMap<String, EventPropertyDescriptor>(); for (EventPropertyDescriptor eventProperty : underlyingEventType.getPropertyDescriptors()) { propertyDesc.add(eventProperty); propertyDescriptorMap.put(eventProperty.getPropertyName(), eventProperty); } for (EventPropertyDescriptor mapProperty : underlyingMapType.getPropertyDescriptors()) { propertyDesc.add(mapProperty); propertyDescriptorMap.put(mapProperty.getPropertyName(), mapProperty); } EventPropertyDescriptor[] propertyDescArr = propertyDesc.toArray(new EventPropertyDescriptor[propertyDesc.size()]); return new PropertyDescriptorComposite( propertyDescriptorMap, propertyNamesArr, propertyDescArr); }
public Event parse(String text) { Event event = null; Matcher matcher = pattern.matcher(text); if (matcher.find() && matcher.groupCount() == 4) { event = new Event(); event.setEventType(EventType.valueOf(matcher.group(1))); event.setTimestamp(Long.valueOf(matcher.group(2))); event.setPath(matcher.group(3)); event.setContentHash(matcher.group(4)); } return event; }
public JSONObject toJSON() { try { JSONObject o = new JSONObject(); o.put("type", mEventType.toString()); o.put("ms", getDuration()); o.put("orientation", mOrientation.toString()); o.put("pages", PageflipUtils.join(",", mPages)); o.put("view_session", mViewSession); return o; } catch (JSONException e) { SgnLog.d(TAG, e.getMessage(), e); } return new JSONObject(); }