2 new revisions:
Revision: e8f79c7f883b
Branch: default
Author: enricogiurin
Date: Fri May 24 23:13:01 2013
Log: issue-120
http://code.google.com/p/jugevents/source/detail?r=e8f79c7f883b&repo=version3
Revision: 17e004354209
Branch: default
Author: enricogiurin
Date: Fri May 24 23:13:44 2013
Log: issue-118
http://code.google.com/p/jugevents/source/detail?r=17e004354209&repo=version3
==============================================================================
Revision: e8f79c7f883b
Branch: default
Author: enricogiurin
Date: Fri May 24 23:13:01 2013
Log: issue-120
http://code.google.com/p/jugevents/source/detail?r=e8f79c7f883b&repo=version3
Added:
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/ArchiveVideoResourceDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/EventDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/EventLinkDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/EventResourceDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/FlickrResourceDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/JUGDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/JuggerDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/LinkedEventDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/ParticipantDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/SlideShareResourceDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/SpeakerDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/YouTubeResourceDao.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/ArchiveVideoResource.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Event.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/EventLink.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/EventResource.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/FlickrResource.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/JUG.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Jugger.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/LinkedEvent.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Participant.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Registration.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/SlideShareResource.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Speaker.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/YouTubeResource.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/GravatarUtils.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/JUGValidator.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/NotPassedEventsFilterFactory.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/TextFilterUtils.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/mime/InvalidMagicMimeEntryException.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/mime/MagicMimeEntry.java
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/mime/MimeUtil.java
Deleted:
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/ArchiveVideoResourceDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/EventDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/EventLinkDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/EventResourceDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/FlickrResourceDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/JUGDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/JuggerDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/LinkedEventDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/ParticipantDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/SlideShareResourceDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/SpeakerDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/YouTubeResourceDao.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/ArchiveVideoResource.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/Event.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/EventLink.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/EventResource.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/FlickrResource.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/JUG.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/Jugger.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/LinkedEvent.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/Participant.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/Registration.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/SlideShareResource.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/Speaker.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/YouTubeResource.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/util/GravatarUtils.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/util/JUGValidator.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/util/NotPassedEventsFilterFactory.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/util/TextFilterUtils.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/util/mime/InvalidMagicMimeEntryException.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/util/mime/MagicMimeEntry.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/util/mime/MimeUtil.java
Modified:
/jugevents/jugevents-core/pom.xml
/jugevents/jugevents-web/src/main/java/it/jugpadova/JugEventsDaos.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/bean/EditJugger.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/bean/NewJugger.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/bean/NewsMessage.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/bean/Registration.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/bean/SpeakerBean.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blo/EventBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blo/EventResourceBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blo/FilterBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blo/JugBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blo/JuggerBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blo/LinkedEventBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blo/ParticipantBadgeBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blo/ParticipantBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blo/SpeakerBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blol/FeedsBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blol/SchedulerBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/blol/ServicesBo.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/AddParticipantController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/AdminLinkedEventController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/BinController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/ConfirmController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/EventController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/EventEditController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/EventSearchController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/JuggerChangePasswordController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/JuggerController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/JuggerEditController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/JuggerEnableController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/JuggerRegistrationController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/ParticipantRegistrationController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/controllers/PasswordRecoveryController.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/exception/RegistrationNotOpenException.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/util/OpenIdUserDetailsService.java
/jugevents/jugevents-web/src/main/java/it/jugpadova/util/Utilities.java
/jugevents/jugevents-web/src/main/webapp/WEB-INF/applicationContext.xml
/jugevents/jugevents-web/src/main/webapp/WEB-INF/jsp/event/resources.jsp
/jugevents/jugevents-web/src/main/webapp/WEB-INF/jsp/event/search.jsp
/jugevents/jugevents-web/src/test/java/it/jugpadova/JugEventsBaseTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/JugEventsControllerTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/SanityTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/bean/SpeakerBeanTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/blo/EventRegistrationOpenTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/blo/JugBoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/blo/ParticipantBadgeBoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/blol/FeedsBoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/blol/SchedulerBoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/controllers/EventEditControllerTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/dao/EventDaoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/dao/EventResourceDaoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/dao/JUGDaoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/dao/JuggerDaoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/dao/ParticipantDaoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/dao/SpeakerDaoTest.java
/jugevents/jugevents-web/src/test/java/it/jugpadova/util/mime/MimeUtilTest.java
/jugevents/pom.xml
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/ArchiveVideoResourceDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+import org.jugevents.core.po.ArchiveVideoResource;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+@Dao(entity = ArchiveVideoResource.class)
+public interface ArchiveVideoResourceDao extends
GenericDao<ArchiveVideoResource, Long> {
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/EventDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,53 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+
+import java.util.Date;
+import java.util.List;
+
+import org.jugevents.core.po.Event;
+import org.lambico.dao.generic.Compare;
+import org.lambico.dao.generic.CompareType;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+@Dao(entity = Event.class)
+public interface EventDao extends GenericDao<Event, Long> {
+
+ List<Event> findByLocation(String location);
+
+ List<Event> findCurrentEvents();
+
+ List<Event> findEventByPartialLocation(String location);
+
+ List<Event> findEventByPartialLocationAndJugOwner(String
partialLocation,
+ String jugOwner);
+
+ List<Event> findUpcomingEvents(Date notAfter);
+
+ List<Event> findNewEvents(Date notBefore);
+
+ /**
+ * Retrieves all events by partial title.
+ * @param partialTitle
+ * @return
+ */
+ List<Event> findByTitle(@Compare(CompareType.ILIKE) String
partialTitle);
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/EventLinkDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+import org.jugevents.core.po.EventLink;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+@Dao(entity = EventLink.class)
+public interface EventLinkDao extends GenericDao<EventLink, Long> {
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/EventResourceDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+import org.jugevents.core.po.EventResource;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+@Dao(entity = EventResource.class)
+public interface EventResourceDao extends GenericDao<EventResource, Long> {
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/FlickrResourceDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+import org.jugevents.core.po.FlickrResource;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+@Dao(entity = FlickrResource.class)
+public interface FlickrResourceDao extends GenericDao<FlickrResource,
Long> {
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/JUGDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,50 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+
+import java.util.List;
+
+import org.jugevents.core.po.JUG;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+/**
+ * @author Enrico Giurin
+ *
+ */
+@Dao(entity = JUG.class)
+public interface JUGDao extends GenericDao<JUG, Long> {
+
+ JUG findByName(String jugName);
+
+ JUG findByICName(String jugName);
+
+ List<JUG> findByPartialName(String s);
+
+ List<JUG> findByPartialJugNameAndCountry(String partialName,
+ String partialCountryEnglishName);
+
+ List<JUG> findByNameAndCountryEN(String name, String
countryEnglishName);
+
+ List<JUG> findByPartialJugNameAndCountryAndContinent(String
partialName,
+ String partialCountry, String partialContinent);
+
+ JUG findByInternalFriendlyName(String internalFriendlyName);
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/JuggerDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,47 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+
+import java.util.List;
+
+import org.jugevents.core.po.Jugger;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+/**
+ * @author Enrico Giurin <
enrico...@gmail.com>
+ * @author Lucio Benfante <
lucio.b...@gmail.com>
+ */
+@Dao(entity = Jugger.class)
+public interface JuggerDao extends GenericDao<Jugger, Long> {
+
+ public List<Jugger> findByPartialJugNameAndCountryAndContinent(
+ String juggerName, String countryLocalName, String continent);
+
+ Jugger searchByUsername(String username);
+
+ Jugger findByUsernameAndConfirmationCode(String username, String
confirmationCode);
+
+ Jugger findByUsernameAndChangePasswordCode(String username, String
changePasswordCode);
+
+ Jugger findByEmail(String email);
+
+ List<Jugger> findAllOrderByUsername();
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/LinkedEventDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,32 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+
+import java.util.List;
+
+import org.jugevents.core.po.LinkedEvent;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+@Dao(entity = LinkedEvent.class)
+public interface LinkedEventDao extends GenericDao<LinkedEvent, Long> {
+
+ public List<LinkedEvent> findExposedEvents();
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/ParticipantDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,58 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+
+import java.util.List;
+
+import org.jugevents.core.po.Participant;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+@Dao(entity = Participant.class)
+public interface ParticipantDao extends GenericDao<Participant, Long> {
+
+ List<Participant> findByEmailAndConfirmationCodeAndConfirmed(String
email,
+ String confirmationCode, Boolean confirmed);
+
+ Participant findByEmailAndConfirmationCode(String email,
+ String confirmationCode);
+
+ List<Participant> findConfirmedParticipantsByEventId(Long id);
+
+ List<Participant>
findConfirmedParticipantsByEventIdOrderByLastNameAndFirstName(
+ Long id);
+
+ List<Participant> findNotConfirmedParticipantsByEventId(Long id);
+
+ List<Participant> findCancelledParticipantsByEventId(Long id);
+
+ List<Participant> findParticipantByEmailAndEventId(String email,
+ Long eventId);
+
+ List<Participant> findParticipantsByEventId(Long eventId);
+
+ List<Participant> findPresentParticipantsByEventId(Long eventId);
+
+ List<Participant> findWinningParticipantsByEventId(Long eventId);
+
+ List<Participant> findNonwinningParticipantsByEventId(Long eventId);
+
+ List<Participant> findParticipantsToBeReminded();
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/SlideShareResourceDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+import org.jugevents.core.po.SlideShareResource;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+@Dao(entity = SlideShareResource.class)
+public interface SlideShareResourceDao extends
GenericDao<SlideShareResource, Long> {
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/SpeakerDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,61 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+import java.util.List;
+
+import org.jugevents.core.po.Event;
+import org.jugevents.core.po.Speaker;
+import org.lambico.dao.generic.Compare;
+import org.lambico.dao.generic.CompareType;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+/**
+ * DAO associated to Speaker po.
+ * @author Enrico Giurin
+ *
+ */
+@Dao(entity = Speaker.class)
+public interface SpeakerDao extends GenericDao<Speaker, Long> {
+
+ /**
+ * Retrieves all the events in which the speaker, identified by
partial email, has been teacher.
+ * @param speakerEmail
+ * @return
+ */
+ List<Event> findEventsByPartialSpeakerEmail(String speakerEmail);
+
+ /**
+ * Retrieves all the speakers which have presented in events
+ * identified by partial eventTitle.
+ * @param eventTitle
+ * @return
+ */
+ List<Speaker> findSpeakersByPartialEventTitle(String eventTitle);
+
+ /**
+ * Retrieves all the speakers identified by a partial resume.
+ * @param resume
+ * @return
+ */
+ List<Speaker> findByResume(@Compare(CompareType.ILIKE) String resume);
+
+ List<Speaker> allByEvent(Long id);
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/dao/YouTubeResourceDao.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.dao;
+
+import org.jugevents.core.po.YouTubeResource;
+import org.lambico.dao.generic.Dao;
+import org.lambico.dao.generic.GenericDao;
+
+@Dao(entity = YouTubeResource.class)
+public interface YouTubeResourceDao extends GenericDao<YouTubeResource,
Long> {
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/ArchiveVideoResource.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,52 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+/**
+ * A SlideShare (
www.slideshare.net) resource.
+ *
+ * @author Lucio Benfante (<a
href="
lucio.b...@jugpadova.it">
lucio.b...@jugpadova.it</a>)
+ * @version $Revision$
+ */
+@Entity
+@DiscriminatorValue("ArchiveVideo")
+public class ArchiveVideoResource extends EventResource {
+ private String flashVideoUrl;
+ private String detailsUrl;
+
+ public String getDetailsUrl() {
+ return detailsUrl;
+ }
+
+ public void setDetailsUrl(String detailsUrl) {
+ this.detailsUrl = detailsUrl;
+ }
+
+ public String getFlashVideoUrl() {
+ return flashVideoUrl;
+ }
+
+ public void setFlashVideoUrl(String flashVideoUrl) {
+ this.flashVideoUrl = flashVideoUrl;
+ }
+
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Event.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,514 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jugevents.core.po;
+
+
+
+import org.jugevents.core.util.Utilities;
+import java.io.Serializable;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import
javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+import org.hibernate.search.annotations.DateBridge;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Resolution;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.validator.constraints.NotBlank;
+import org.jugevents.core.util.NotPassedEventsFilterFactory;
+import org.jugevents.core.util.TextFilterUtils;
+
+/**
+ * An event.
+ *
+ * @author Lucio Benfante
+ */
+@Entity
+@Indexed
+@NamedQueries(value = {
+ @NamedQuery(name = "Event.findCurrentEvents", query =
+ "from Event e where e.startDate >= current_date()"),
+ @NamedQuery(name = "Event.findEventByPartialLocation", query =
+ "from Event e where lower(e.location) like lower(?) order by
e.location"),
+ @NamedQuery(name = "Event.findEventByPartialLocationAndJugOwner",
+ query =
+ "from Event e where lower(e.location) like lower(?) and
e.jugOwner.name = ? order by e.location"),
+ @NamedQuery(name = "Event.findUpcomingEvents",
+ query =
+ "from Event e where e.startDate >= current_date() and e.startDate <= ?
order by e.startDate"),
+ @NamedQuery(name = "Event.findNewEvents",
+ query =
+ "from Event e where e.startDate >= current_date() and e.creationDate
>= ? order by e.startDate")
+})
+@FullTextFilterDefs({
+ @FullTextFilterDef(name = "notPassedEvents", impl =
+ NotPassedEventsFilterFactory.class)
+})
+public class Event implements org.lambico.po.hibernate.Entity,
Serializable {
+
+ protected Long id;
+ private String title;
+ private Date startDate;
+ private String startTime;
+ private Date endDate;
+ private String endTime;
+ private String location;
+ private String directions;
+ private String description;
+ private String filter = "Textile";
+ private JUG jugOwner;
+
+ private Date creationDate;
+ private Registration registration;
+ private List<EventResource> eventResources;
+ private List<Speaker> speakers = new ArrayList<Speaker>();
+ private byte[] badgeTemplate;
+ private Date reminderDate;
+ private boolean activeReminder = false;
+ public final static int NUM_OF_DAYS_REMINDER_BEFORE_EVENT = 2;
+
+ /**
+ * Get the entity id.
+ *
+ * @return the entity id.
+ */
+ @Id
+ @DocumentId
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ public Long getId() {
+ return
this.id;
+ }
+
+ public void setId(Long id) {
+
this.id = id;
+ }
+
+
+
+
+ @Column(length = 1024)
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ public String getDirections() {
+ return directions;
+ }
+
+ public void setDirections(String directions) {
+ this.directions = directions;
+ }
+
+ public String getFilter() {
+ return filter;
+ }
+
+ public void setFilter(String filter) {
+ this.filter = filter;
+ }
+ private List<Participant> participants;
+
+ /** Creates a new instance of Event */
+ public Event() {
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ @NotBlank
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Temporal(value = TemporalType.DATE)
+ @Field(index = Index.UN_TOKENIZED, store = Store.YES)
+ @DateBridge(resolution = Resolution.DAY)
+ @NotNull
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Date startDate) {
+ this.startDate = startDate;
+ }
+
+ public String getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(String startTime) {
+ this.startTime = startTime;
+ }
+
+ @Temporal(value = TemporalType.DATE)
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Date endDate) {
+ this.endDate = endDate;
+ }
+
+ public String getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(String endTime) {
+ this.endTime = endTime;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ @NotBlank
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ @Lob
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @OneToMany(mappedBy = "event", cascade = {CascadeType.ALL})
+ public List<Participant> getParticipants() {
+ return participants;
+ }
+
+ public void setParticipants(List<Participant> participants) {
+ this.participants = participants;
+ }
+
+ public void addParticipant(Participant participant) {
+ if (this.participants == null) {
+ this.participants =
+ new LinkedList<Participant>();
+ }
+ this.participants.add(participant);
+ participant.setEvent(this);
+ }
+
+ @Temporal(value = TemporalType.TIMESTAMP)
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ @Embedded
+ @Valid
+ public Registration getRegistration() {
+ return registration;
+ }
+
+ public void setRegistration(Registration registration) {
+ this.registration = registration;
+ }
+
+ @OneToMany(mappedBy = "event", cascade = {CascadeType.ALL})
+ public List<EventResource> getEventResources() {
+ return eventResources;
+ }
+
+ public void setEventResources(List<EventResource> eventResources) {
+ this.eventResources = eventResources;
+ }
+
+ @OneToMany(mappedBy = "event", orphanRemoval = true, cascade =
CascadeType.ALL)
+ public List<Speaker> getSpeakers() {
+ if (this.speakers == null) {
+ this.speakers = new ArrayList<Speaker>();
+ }
+ return speakers;
+ }
+
+ public void setSpeakers(List<Speaker> speakers) {
+ this.speakers = speakers;
+ }
+
+ @Lob
+ @Basic(fetch = FetchType.LAZY)
+ public byte[] getBadgeTemplate() {
+ return badgeTemplate;
+ }
+
+ public void setBadgeTemplate(byte[] badgeTemplate) {
+ this.badgeTemplate = badgeTemplate;
+ }
+
+ @Transient
+ public int getNumberOfParticipants() {
+ int result = 0;
+ if (getParticipants() != null) {
+ for (Participant p : getParticipants()) {
+ if (p.hasValidRegistration()) {
+ result++;
+ }
+ }
+ }
+ return result;
+ }
+
+ @Transient
+ public String getFilteredDirections() {
+ String filteredDirections =
+ TextFilterUtils.filterText(this.getDirections(),
this.getFilter(),
+ false);
+ return filteredDirections;
+ }
+
+ @Transient
+ public String getFilteredDescription() {
+ String filteredDescription =
+ TextFilterUtils.filterText(this.getDescription(),
this.getFilter(),
+ false);
+ return filteredDescription;
+ }
+
+ /**
+ * Decide if the registration is open or not, based on the event data
+ *
+ * @param event The event
+ * @return true if the registration is open. False, otherwise.
+ */
+ @Transient
+ public boolean getRegistrationOpen() {
+ boolean result = false;
+ final Registration reg = this.getRegistration();
+ if (thereAreNoRegistrationRules(reg)) { // old way
+ result = todayIsBeforeTheEndOfTheStartDay();
+ } else {
+ if (reg.getEnabled().booleanValue()) {
+ if (reg.getManualActivation() != null) {
+ result = reg.getManualActivation();
+ } else {
+ // TODO complete with other rules
+ if (partecipantsAreUnderTheLimit(reg) &&
todayIsInTheRegistrationInterval(
+ reg)) {
+ result = true;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return the name of the hosting organization.
+ *
+ * @return The name of the hosting organization. Or "" if there is no
hosting organization.
+ */
+ @Transient
+ public String getHostingOrganizationName() {
+ String result = "";
+ if (this.getJugOwner() != null) {
+ result = this.getJugOwner().getName();
+ }
+ return result;
+ }
+
+ /**
+ * Return the URL of the hosting organization.
+ *
+ * @return The URL of the hosting organization. Or "" if there is no
hosting organization URL/Web site.
+ */
+ @Transient
+ public String getHostingOrganizationUrl() {
+ String result = "";
+ if (this.getJugOwner() != null) {
+ result = this.getJugOwner().getWebSiteUrl();
+ }
+ return result;
+ }
+
+ private boolean partecipantsAreUnderTheLimit(final Registration reg) {
+ return reg.getMaxParticipants() == null ||
this.getNumberOfParticipants() < reg.
+ getMaxParticipants().longValue();
+ }
+
+ public boolean todayIsBeforeTheEndOfTheStartDay() {
+ return Utilities.todayIsBeforeDate(this.startDate);
+ }
+
+ private boolean thereAreNoRegistrationRules(final Registration reg) {
+ return reg == null || (reg != null && reg.getEnabled() &&
reg.getManualActivation() == null && reg.
+ getStartRegistration()
+ == null && reg.getEndRegistration() == null &&
reg.getMaxParticipants() == null);
+ }
+
+ private boolean todayIsInTheRegistrationInterval(Registration reg) {
+ boolean result = true;
+ Date now = new Date();
+ if ((reg.getStartRegistration() != null &&
reg.getStartRegistration().
+ compareTo(now) > 0) || (reg.getEndRegistration() != null
&& reg.getEndRegistration().
+ compareTo(now) < 0) || (reg.getEndRegistration() == null
+ && !todayIsBeforeTheEndOfTheStartDay())) {
+ result = false;
+ }
+ return result;
+ }
+
+ public void setReminderDate(Date reminderDate) {
+ this.reminderDate = reminderDate;
+ }
+
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ public Date getReminderDate() {
+ return reminderDate;
+ }
+
+ /**
+ * Returns a convenient subject for the mail relating to the event
itself.
+ * Possible usages are for jug contact's email and speakers.
+ * The value is encoded.
+ * @return
+ */
+ @Transient
+ public String getSubjectForEmailContact() throws
UnsupportedEncodingException {
+ return URLEncoder.encode(this.getTitle(), "UTF-8");
+ }
+
+ /**
+ * This method is called from the EventEditController to calculate
+ * the date of reminder date.
+ * Currently reminderDate corresponds to 2 days earlier the event
+ * start date.
+ */
+ public void updateReminderDate() {
+ if (this.getActiveReminder()) {
+ GregorianCalendar gc = new GregorianCalendar();
+ gc.setTime(this.getStartDate());
+ gc.add(GregorianCalendar.DAY_OF_YEAR,
-NUM_OF_DAYS_REMINDER_BEFORE_EVENT);
+ this.setReminderDate(gc.getTime());
+ } else {
+ this.setReminderDate(null);
+ }
+
+ }
+
+ @Transient
+ public boolean getActiveReminder() {
+ return activeReminder;
+ }
+
+ public void setActiveReminder(boolean activeReminder) {
+ this.activeReminder = activeReminder;
+ }
+
+ @Transient
+ public boolean isEventInThePast() {
+ return !Utilities.todayIsBeforeDate(this.endDate);
+ }
+
+ /**
+ * Default implementation of the equals method.
+ * It return true if the objects are of the same type and have
+ * the same id.
+ *
+ * @param obj The object to compare with this
+ * @return true if the objects are equals
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ boolean result = false;
+ if (obj != null) {
+ String className = obj.getClass().getName();
+ if (className.indexOf("$$EnhancerByCGLIB$$") > 0) {
+ className = className.substring(0,
className.indexOf("$$EnhancerByCGLIB$$"));
+ }
+ if (this.getClass().getName().equals(className)) {
+ if (this.getId() != null && this.getId().equals(((Event)
obj).getId())) {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Default implementation of the hashcode method for an Entity.
+ * It return the hascode of the Id, if the Id is not null.
+ * It return the hascode of the Object, if the Id is null.
+ *
+ * @return The hashcode of the entity instance.
+ */
+ @Override
+ public int hashCode() {
+ int result;
+ if (this.getId() != null) {
+ result = this.getId().hashCode();
+ } else {
+ result = super.hashCode();
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return this.getClass().getName() + "[id=" +
this.id + "]";
+ }
+ @ManyToOne
+ public JUG getJugOwner() {
+ return jugOwner;
+ }
+
+ public void setJugOwner(JUG jugOwner) {
+ this.jugOwner = jugOwner;
+ }
+
+
+
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/EventLink.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,49 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Transient;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * A web link resource.
+ *
+ * @author Lucio Benfante (<a
href="
lucio.b...@jugpadova.it">
lucio.b...@jugpadova.it</a>)
+ * @version $Revision$
+ */
+@Entity
+@DiscriminatorValue("Link")
+public class EventLink extends EventResource {
+ private String url;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ @Transient
+ public String getAbbreviatedUrl() {
+ return StringUtils.abbreviate(url, 40);
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/EventResource.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,55 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.ManyToOne;
+import org.lambico.po.hibernate.EntityBase;
+
+/**
+ * Resource associated to an event.
+ *
+ * @author lucio
+ */
+@Entity
+@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
+public abstract class EventResource extends EntityBase {
+ private String description;
+ private Event event;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @ManyToOne
+ public Event getEvent() {
+ return event;
+ }
+
+ public void setEvent(Event event) {
+ this.event = event;
+ }
+
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/FlickrResource.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+/**
+ * A Flickr (
www.flickr.com) resource.
+ *
+ * @author Lucio Benfante (<a
href="
lucio.b...@jugpadova.it">
lucio.b...@jugpadova.it</a>)
+ * @version $Revision$
+ */
+@Entity
+@DiscriminatorValue("Flickr")
+public class FlickrResource extends EventResource {
+ private String tag;
+
+ public String getTag() {
+ return tag;
+ }
+
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+}
=======================================
--- /dev/null
+++ /jugevents/jugevents-core/src/main/java/org/jugevents/core/po/JUG.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,213 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Transient;
+import javax.validation.Valid;
+import org.apache.commons.lang.StringUtils;
+import org.hibernate.validator.constraints.Email;
+import org.hibernate.validator.constraints.NotBlank;
+import org.lambico.po.hibernate.EntityBase;
+
+import org.parancoe.plugins.world.Country;
+
+/**
+ * Represents Java User Group informations.
+ * @author Enrico Giurin
+ *
+ */
+@Entity
+@NamedQueries(value = {@NamedQuery(name = "JUG.findByPartialName", query =
+"from JUG j where upper(
j.name) like upper(?) order by
j.name asc"),
@NamedQuery(name =
+"JUG.findByPartialJugNameAndCountry", query =
+"from JUG jug where upper(
jug.name) like upper(?) and
upper(jug.country.englishName) like upper(?) order by
jug.name asc"),
@NamedQuery(name =
+"JUG.findByNameAndCountryEN", query =
+"from JUG jug where upper(
jug.name) = upper(?) and
upper(jug.country.englishName) = upper(?) order by
jug.name asc"),
+@NamedQuery(name =
+"JUG.findByICName", query =
+"from JUG jug where upper(
jug.name) = upper(?) order by
jug.name asc"),
@NamedQuery(name =
+"JUG.findByPartialJugNameAndCountryAndContinent", query =
+"from JUG j where upper(
j.name) like upper(?) and
upper(j.country.localName) like upper(?) and
upper(
j.country.continent.name) like upper(?) order by
j.name asc")
+})
+// TODO V3: reimplement JUG validator. @Validator(value =
JUGValidator.class)
+public class JUG extends EntityBase {
+
+ private static final long serialVersionUID = -40063909128565029L;
+ /**
+ * JUG name
+ */
+ private String name;
+ private Country country;
+ private String webSite;
+ private Double latitude;
+ private Double longitude;
+ private String infos;
+ private Boolean modifiedKmlData;
+ private byte[] logo;
+ private String contactName;
+ private String contactEmail;
+ private String timeZoneId;
+ private byte[] certificateTemplate;
+ private String internalFriendlyName;
+
+ @NotBlank
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+
this.name = name;
+ }
+
+ @ManyToOne
+ @Valid
+ public Country getCountry() {
+ return country;
+ }
+
+ public void setCountry(Country country) {
+ this.country = country;
+ }
+
+ public Double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(Double latitude) {
+ this.latitude = latitude;
+ }
+
+ public Double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(Double longitude) {
+ this.longitude = longitude;
+ }
+
+ public String getWebSite() {
+ return webSite;
+ }
+
+ public void setWebSite(String webSite) {
+ this.webSite = webSite;
+ }
+
+ @Column(length = 1024)
+ public String getInfos() {
+ return infos;
+ }
+
+ public void setInfos(String infos) {
+ this.infos = infos;
+ }
+
+ public Boolean isModifiedKmlData() {
+ return modifiedKmlData;
+ }
+
+ public void setModifiedKmlData(Boolean modifiedKmlData) {
+ this.modifiedKmlData = modifiedKmlData;
+ }
+
+ @Lob
+ @Basic(fetch = FetchType.LAZY)
+ public byte[] getLogo() {
+ return logo;
+ }
+
+ public void setLogo(byte[] logo) {
+ this.logo = logo;
+ }
+
+ @Lob
+ @Basic(fetch = FetchType.LAZY)
+ public byte[] getCertificateTemplate() {
+ return certificateTemplate;
+ }
+
+ public void setCertificateTemplate(byte[] certificateTemplate) {
+ this.certificateTemplate = certificateTemplate;
+ }
+
+ // TODO V3: warning, not conditional now! Verify if it works as
espected. @Email(applyIf="contactEmail is not blank")
+ @Email
+ public String getContactEmail() {
+ return contactEmail;
+ }
+
+ public void setContactEmail(String contactEmail) {
+ this.contactEmail = contactEmail;
+ }
+
+ public String getContactName() {
+ return contactName;
+ }
+
+ public void setContactName(String contactName) {
+ this.contactName = contactName;
+ }
+
+ public String getTimeZoneId() {
+ return timeZoneId;
+ }
+
+ public void setTimeZoneId(String timeZoneId) {
+ this.timeZoneId = timeZoneId;
+ }
+
+ public String getInternalFriendlyName() {
+ return internalFriendlyName;
+ }
+
+ public void setInternalFriendlyName(String internalFriendlyName) {
+ this.internalFriendlyName = internalFriendlyName;
+ }
+
+ @Transient
+ public String getWebSiteUrl() {
+ String result = this.getWebSite();
+ if (this.getWebSite() != null
&& !this.getWebSite().contains("://")) {
+ result = "http://" + result;
+ }
+ return result;
+ }
+
+ @Transient
+ public String getFriendlyNameEncoded() throws
UnsupportedEncodingException {
+ String result = null;
+ if (StringUtils.isNotBlank(getInternalFriendlyName())) {
+ result = getInternalFriendlyName();
+ } else {
+ result = getName();
+ }
+ return URLEncoder.encode(result, "UTF-8");
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Jugger.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,143 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+import javax.validation.Valid;
+import org.hibernate.validator.constraints.Email;
+import org.hibernate.validator.constraints.NotBlank;
+import org.hibernate.validator.constraints.Range;
+import org.lambico.po.hibernate.EntityBase;
+
+import org.parancoe.plugins.securityevolution.User;
+
+/**
+ * @author Enrico Giurin
+ * @author Lucio Benfante <
lucio.b...@gmail.com>
+ *
+ */
+@Entity
+@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "email" })
})
+@NamedQueries(value = {
+ @NamedQuery(name = "Jugger.searchByUsername", query = "from Jugger j
where j.user.username = ?"),
+ @NamedQuery(name = "Jugger.findByUsernameAndConfirmationCode", query
= "from Jugger j where j.user.username = ? and j.confirmationCode = ?"),
+ @NamedQuery(name = "Jugger.findByUsernameAndChangePasswordCode", query
= "from Jugger j where j.user.username = ? and j.changePasswordCode = ?"),
+ @NamedQuery(name = "Jugger.findByPartialJugNameAndCountryAndContinent",
query = "from Jugger j where upper(
j.jug.name) like upper(?) and
upper(j.jug.country.localName) like upper(?) and
upper(
j.jug.country.continent.name) like upper(?) order by
j.jug.name asc"),
+ @NamedQuery(name = "Jugger.findAllOrderByUsername", query = "from Jugger
j order by j.user.username asc") })
+public class Jugger extends EntityBase {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6005123717507782857L;
+
+ private String firstName;
+
+ private String lastName;
+
+ private String email;
+
+ private JUG jug;
+
+ private User user;
+
+ private String confirmationCode;
+
+ private String changePasswordCode;
+
+
+
+
+ public Jugger() {
+ }
+
+ @NotBlank
+ @Email
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ @NotBlank
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ @NotBlank
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @Valid
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ public String getConfirmationCode() {
+ return confirmationCode;
+ }
+
+ public void setConfirmationCode(String confirmationCode) {
+ this.confirmationCode = confirmationCode;
+ }
+
+ public String getChangePasswordCode() {
+ return changePasswordCode;
+ }
+
+ public void setChangePasswordCode(String changePasswordCode) {
+ this.changePasswordCode = changePasswordCode;
+ }
+
+ @ManyToOne
+ @Valid
+ public JUG getJug() {
+ return jug;
+ }
+
+ public void setJug(JUG jug) {
+ this.jug = jug;
+ }
+
+
+
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/LinkedEvent.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,139 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import java.util.Date;
+import javax.persistence.Entity;
+import javax.persistence.Lob;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Temporal;
+import javax.validation.constraints.NotNull;
+import org.hibernate.validator.constraints.NotBlank;
+import org.lambico.po.hibernate.EntityBase;
+
+/**
+ * An event linked from another source, usually from a sponsor.
+ *
+ * @author Lucio Benfante
+ */
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "LinkedEvent.findExposedEvents", query =
+ "from LinkedEvent e where e.expositionStartDate <= current_date() and
e.expositionEndDate >= current_date() order by e.startDate")
+})
+/* TODO V3: redo date validation.
+@Expressions({
+ @Expression(errorCode = "startDateAfterEndDate",
+ message = "?startDateAfterEndDate?",
+ applyIf = "startDate is not null and endDate is not null",
+ value = "startDate <= endDate"),
+ @Expression(errorCode = "expositionStartDateAfterExpositionEndDate",
+ message = "?expositionStartDateAfterExpositionEndDate?",
+ applyIf =
+ "expositionStartDate is not null and expositionEndDate is not null",
+ value = "expositionStartDate <= expositionEndDate")
+}) */
+public class LinkedEvent extends EntityBase {
+
+ protected String title;
+ protected String url;
+ protected String urlLabel;
+ protected byte[] background;
+ protected Date startDate;
+ protected Date endDate;
+ protected Date expositionStartDate;
+ protected Date expositionEndDate;
+
+ @Lob
+ public byte[] getBackground() {
+ return background;
+ }
+
+ public void setBackground(byte[] background) {
+ this.background = background;
+ }
+
+ @NotBlank
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @NotBlank
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ @NotBlank
+ public String getUrlLabel() {
+ return urlLabel;
+ }
+
+ public void setUrlLabel(String urlLabel) {
+ this.urlLabel = urlLabel;
+ }
+
+ @Temporal(javax.persistence.TemporalType.DATE)
+ @NotNull
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Date endDate) {
+ this.endDate = endDate;
+ }
+
+ @Temporal(javax.persistence.TemporalType.DATE)
+ @NotNull
+ public Date getExpositionEndDate() {
+ return expositionEndDate;
+ }
+
+ public void setExpositionEndDate(Date expositionEndDate) {
+ this.expositionEndDate = expositionEndDate;
+ }
+
+ @Temporal(javax.persistence.TemporalType.DATE)
+ @NotNull
+ public Date getExpositionStartDate() {
+ return expositionStartDate;
+ }
+
+ public void setExpositionStartDate(Date expositionStartDate) {
+ this.expositionStartDate = expositionStartDate;
+ }
+
+ @Temporal(javax.persistence.TemporalType.DATE)
+ @NotNull
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Date startDate) {
+ this.startDate = startDate;
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Participant.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,293 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import org.apache.commons.lang.StringUtils;
+import org.hibernate.validator.constraints.Email;
+import org.hibernate.validator.constraints.Length;
+import org.hibernate.validator.constraints.NotBlank;
+import org.jugevents.core.util.GravatarUtils;
+import org.lambico.po.hibernate.EntityBase;
+
+/**
+ * The participant of an event.
+ *
+ * @author Lucio Benfante (<a
href="
lucio.b...@jugpadova.it">
lucio.b...@jugpadova.it</a>)
+ * @version $Revision$
+ */
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "Participant.findParticipantByEmailAndEventId",
+ query = "from Participant p where p.email = ? and
p.event.id = ?"),
+ @NamedQuery(name = "Participant.findParticipantsByEventId",
+ query = "from Participant p where
p.event.id = ?"),
+ @NamedQuery(name = "Participant.findConfirmedParticipantsByEventId",
+ query =
+ "from Participant p where
p.event.id = ? and p.confirmed = true and
(p.cancelled is null or p.cancelled = false) order by p.creationDate,
p.id"),
+ @NamedQuery(name =
+ "Participant.findConfirmedParticipantsByEventIdOrderByLastNameAndFirstName",
+ query =
+ "from Participant p where
p.event.id = ? and p.confirmed = true and
(p.cancelled is null or p.cancelled = false) order by p.lastName,
p.firstName, p.creationDate,
p.id"),
+ @NamedQuery(name = "Participant.findNotConfirmedParticipantsByEventId",
+ query =
+ "from Participant p where
p.event.id = ? and (p.confirmed is null or
p.confirmed = false) and (p.cancelled is null or p.cancelled = false) order
by p.creationDate,
p.id"),
+ @NamedQuery(name = "Participant.findCancelledParticipantsByEventId",
+ query =
+ "from Participant p where
p.event.id = ? and p.cancelled = true order
by p.creationDate,
p.id"),
+ @NamedQuery(name = "Participant.findPresentParticipantsByEventId",
+ query = "from Participant p where
p.event.id = ? and p.attended =
true"),
+ @NamedQuery(name = "Participant.findWinningParticipantsByEventId",
+ query = "from Participant p where
p.event.id = ? and p.winner = true"),
+ @NamedQuery(name = "Participant.findNonwinningParticipantsByEventId",
+ query =
+ "from Participant p where
p.event.id = ? and (p.winner = null or
p.winner = false)"),
+ @NamedQuery(name = "Participant.findParticipantsToBeReminded",
+ query = "from Participant p where p.confirmed = true and
(p.cancelled is null or p.cancelled = false) "
+ + "and p.reminderEnabled = true and p.reminderSentDate is null and
p.event.reminderDate is not null "
+ + "and p.event.reminderDate <= current_date() and current_date() <=
p.event.startDate "
+ + "order by
p.event.id")})
+public class Participant extends EntityBase {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String firstName;
+ private String lastName;
+ private String email;
+ private String confirmationCode;
+ private Boolean confirmed;
+ private Event event;
+ private Date creationDate;
+ private Boolean attended;
+ private Date lastCertificateSentDate;
+ private Date confirmationDate;
+ private Boolean winner;
+ private String note;
+ private Boolean cancelled;
+ private Date cancellationDate;
+ private Boolean reminderEnabled = Boolean.TRUE;
+ private Date reminderSentDate;
+ private Boolean showFullLastName = Boolean.TRUE;
+
+ /** Creates a new instance of Participant */
+ public Participant() {
+ }
+
+ public Boolean getReminderEnabled() {
+ return reminderEnabled;
+ }
+
+ public void setReminderEnabled(Boolean reminderEnabled) {
+ this.reminderEnabled = reminderEnabled;
+ }
+
+ @Temporal(value = TemporalType.TIMESTAMP)
+ public Date getReminderSentDate() {
+ return reminderSentDate;
+ }
+
+ public void setReminderSentDate(Date reminderSentDate) {
+ this.reminderSentDate = reminderSentDate;
+ }
+
+ @NotBlank
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ @NotBlank
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ @NotBlank
+ @Email
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getConfirmationCode() {
+ return confirmationCode;
+ }
+
+ public void setConfirmationCode(String confirmationCode) {
+ this.confirmationCode = confirmationCode;
+ }
+
+ public Boolean getConfirmed() {
+ return confirmed;
+ }
+
+ public void setConfirmed(Boolean confirmed) {
+ this.confirmed = confirmed;
+ }
+
+ @ManyToOne
+ public Event getEvent() {
+ return event;
+ }
+
+ public void setEvent(Event event) {
+ this.event = event;
+ }
+
+ @Temporal(value = TemporalType.TIMESTAMP)
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public Boolean getAttended() {
+ return attended;
+ }
+
+ public void setAttended(Boolean attended) {
+ this.attended = attended;
+ }
+
+ @Temporal(value = TemporalType.TIMESTAMP)
+ public Date getLastCertificateSentDate() {
+ return lastCertificateSentDate;
+ }
+
+ public void setLastCertificateSentDate(Date lastCertificateSentDate) {
+ this.lastCertificateSentDate = lastCertificateSentDate;
+ }
+
+ @Temporal(value = TemporalType.TIMESTAMP)
+ public Date getConfirmationDate() {
+ return confirmationDate;
+ }
+
+ public void setConfirmationDate(Date confirmationDate) {
+ this.confirmationDate = confirmationDate;
+ }
+
+ public Boolean getWinner() {
+ return winner;
+ }
+
+ public void setWinner(Boolean winner) {
+ this.winner = winner;
+ }
+
+ @Length(max = 255)
+ public String getNote() {
+ return note;
+ }
+
+ public void setNote(String note) {
+ this.note = note;
+ }
+
+ public Boolean getCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(Boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ public Date getCancellationDate() {
+ return cancellationDate;
+ }
+
+ public void setCancellationDate(Date cancellationDate) {
+ this.cancellationDate = cancellationDate;
+ }
+
+ public Boolean getShowFullLastName() {
+ return showFullLastName;
+ }
+
+ public void setShowFullLastName(Boolean showFullLastName) {
+ this.showFullLastName = showFullLastName;
+ }
+
+ /**
+ * Evaluate the confirmation to the event.
+ * @return
+ */
+ public boolean canBeConfirmed() {
+ return true;
+ /*
+ if((!cancelled&&!confirmed))
+ return true;
+ return false;
+ */
+ }
+
+ /**
+ * Evaluate the cancellation to the event.
+ * @return
+ */
+ public boolean canBeCancelled() {
+ return confirmed;
+ }
+
+ public boolean hasValidRegistration() {
+ return this.getConfirmed() != null && this.getConfirmed()
&& !(this.getCancelled() != null && this.
+ getCancelled());
+ }
+
+ @Transient
+ public String getGravatarUrl() throws UnsupportedEncodingException {
+ return GravatarUtils.getUrl(email, 69, null, null);
+ }
+
+ @Transient
+ public String getExposedLastName() {
+ String result = "";
+ if (getShowFullLastName() != null && getShowFullLastName()) {
+ result = getLastName();
+ } else {
+ if (StringUtils.isNotBlank(getLastName())) {
+ result = getLastName().trim().charAt(0) + ".";
+ }
+ }
+ return result;
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Registration.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,104 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import java.io.Serializable;
+import java.util.Date;
+import javax.persistence.Embeddable;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import javax.validation.constraints.Min;
+
+/**
+ * Registration data of an event (not participants)
+ *
+ * @author lucio
+ */
+@Embeddable
+/* TODO V3: redo date validation.
+@Expression(errorCode = "startRegistrationAfterEndRegistration",
+message = "?startRegistrationAfterEndRegistration?",
+applyIf = "startRegistration is not null and endRegistration is not null",
+value = "startRegistration <= endRegistration") */
+public class Registration implements Serializable {
+
+ private Boolean enabled = Boolean.TRUE;
+ private Date startRegistration;
+ private Date endRegistration;
+ private Long maxParticipants;
+ private Boolean manualActivation;
+ private Boolean showParticipants = Boolean.FALSE;
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Boolean getManualActivation() {
+ return manualActivation;
+ }
+
+ public void setManualActivation(Boolean manualActivation) {
+ this.manualActivation = manualActivation;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ public Date getEndRegistration() {
+ return endRegistration;
+ }
+
+ public void setEndRegistration(Date endRegistration) {
+ this.endRegistration = endRegistration;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ public Date getStartRegistration() {
+ return startRegistration;
+ }
+
+ public void setStartRegistration(Date startRegistration) {
+ this.startRegistration = startRegistration;
+ }
+
+ @Min(value = 1)
+ public Long getMaxParticipants() {
+ return maxParticipants;
+ }
+
+ public void setMaxParticipants(Long maxParticipants) {
+ this.maxParticipants = maxParticipants;
+ }
+
+ public Boolean getShowParticipants() {
+ return showParticipants;
+ }
+
+ public void setShowParticipants(Boolean showParticipants) {
+ this.showParticipants = showParticipants;
+ }
+
+ @Transient
+ public boolean getRegistrationRulesAreApplied() {
+ return this.enabled && (this.manualActivation == null);
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/SlideShareResource.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,69 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Transient;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * A SlideShare (
www.slideshare.net) resource.
+ *
+ * @author Lucio Benfante (<a
href="
lucio.b...@jugpadova.it">
lucio.b...@jugpadova.it</a>)
+ * @version $Revision$
+ */
+@Entity
+@DiscriminatorValue("SlideShare")
+public class SlideShareResource extends EventResource {
+ private String url;
+ private String resourceId;
+ private String embedCode;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ @Column(length=2048)
+ public String getEmbedCode() {
+ return embedCode;
+ }
+
+ public void setEmbedCode(String embedCode) {
+ this.embedCode = embedCode;
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ @Transient
+ public String getAbbreviatedUrl() {
+ return StringUtils.abbreviate(url, 40);
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/Speaker.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,269 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import java.io.Serializable;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import
javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Transient;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.validator.constraints.Email;
+import org.hibernate.validator.constraints.NotBlank;
+import org.hibernate.validator.constraints.URL;
+import org.jugevents.core.util.TextFilterUtils;
+
+/**
+ * Represents information about the speaker of the event.
+ * @author Enrico Giurin
+ *
+ */
+@Entity
+@Indexed
+@NamedQueries(value = {
+ @NamedQuery(name = "Speaker.findEventsByPartialSpeakerEmail", query =
+ "select e from Event e, Speaker s where s.event=e and upper(s.email)
like upper(?)"),
+ @NamedQuery(name = "Speaker.allByEvent", query =
+ "select s from Event e, Speaker s where s.event=e and
e.id=?"),
+ @NamedQuery(name = "Speaker.findSpeakersByPartialEventTitle", query =
+ "select s from Event e, Speaker s where s.event=e and upper(e.title)
like upper(?)")})
+ /* TODO V3: is it working?
+@FullTextFilterDefs({
+ @FullTextFilterDef(name = "onlyMyJUG", impl =
+ SpeakerFilterFactory.class)
+})*/
+public class Speaker implements org.lambico.po.hibernate.Entity,
Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private static final Logger logger =
+ LoggerFactory.getLogger(Speaker.class);
+ protected Long id;
+ private String firstName;
+ private String lastName;
+ private String email;
+ private String url;
+ private String skypeId;
+ private byte[] picture;
+ private String resume;
+ private Event event;
+ private String filter = "Textile";
+ private Long indexSpeaker;
+
+ @Transient
+ public Long getIndexSpeaker() {
+ return indexSpeaker;
+ }
+
+ public void setIndexSpeaker(Long indexSpeaker) {
+ this.indexSpeaker = indexSpeaker;
+ }
+
+ @Transient
+ public String getFilter() {
+ return filter;
+ }
+
+ public void setFilter(String filter) {
+ this.filter = filter;
+ }
+
+ /**
+ * Get the entity id.
+ *
+ * @return the entity id.
+ */
+ @Id
+ @DocumentId
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ public Long getId() {
+ return
this.id;
+ }
+
+ public void setId(Long id) {
+
this.id = id;
+ }
+
+ //set size to 1MB because BLOB of MySQL is not enough to store
+ //binary data bigger than 64k
+ @Lob
+ @Basic(fetch = FetchType.LAZY)
+ @Column(length = 1048576)
+ public byte[] getPicture() {
+ return picture;
+ }
+
+ public void setPicture(byte[] picture) {
+ if ((picture == null) || (picture.length == 0)) {
+ //TODO manage in a clean way when picture is null
+ logger.debug("Trying to set null picture has failed");
+ return;
+ }
+ this.picture = picture;
+ }
+
+ @Column(length = 4096)
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ @NotBlank
+ public String getResume() {
+ return resume;
+ }
+
+ public void setResume(String resume) {
+ this.resume = resume;
+ }
+
+ public void setEvent(Event event) {
+ this.event = event;
+ }
+
+ @ManyToOne(targetEntity=Event.class)
+ public Event getEvent() {
+ return event;
+ }
+
+ public String getSkypeId() {
+ return skypeId;
+ }
+
+ public void setSkypeId(String skypeId) {
+ this.skypeId = skypeId;
+ }
+
+ @NotBlank
+ @Email
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ @URL
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ @NotBlank
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ @NotBlank
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ @Transient
+ public String getFilteredPreview() {
+ String filteredPreview =
+ TextFilterUtils.filterText(this.getResume(), this.getFilter(),
+ false);
+ return filteredPreview;
+ }
+
+ public Speaker copyOfInstance() {
+ try {
+ return (Speaker) BeanUtils.cloneBean(this);
+ } catch (Exception e) {
+ logger.error("Failing to get a copy of Speaker instance: " +
this.toString(), e);
+ return null;
+ }
+ }
+
+ /**
+ * Default implementation of the equals method.
+ * It return true if the objects are of the same type and have
+ * the same id.
+ *
+ * @param obj The object to compare with this
+ * @return true if the objects are equals
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ boolean result = false;
+ if (obj != null) {
+ String className = obj.getClass().getName();
+ if (className.indexOf("$$EnhancerByCGLIB$$") > 0) {
+ className = className.substring(0,
className.indexOf("$$EnhancerByCGLIB$$"));
+ }
+ if (this.getClass().getName().equals(className)) {
+ if (this.getId() != null && this.getId().equals(((Speaker)
obj).getId())) {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Default implementation of the hashcode method for an Entity.
+ * It return the hascode of the Id, if the Id is not null.
+ * It return the hascode of the Object, if the Id is null.
+ *
+ * @return The hashcode of the entity instance.
+ */
+ @Override
+ public int hashCode() {
+ int result;
+ if (this.getId() != null) {
+ result = this.getId().hashCode();
+ } else {
+ result = super.hashCode();
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return this.getClass().getName() + "[id=" +
this.id + "]";
+ }
+
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/po/YouTubeResource.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.po;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+/**
+ * A SlideShare (
www.slideshare.net) resource.
+ *
+ * @author Lucio Benfante (<a
href="
lucio.b...@jugpadova.it">
lucio.b...@jugpadova.it</a>)
+ * @version $Revision$
+ */
+@Entity
+@DiscriminatorValue("YouTube")
+public class YouTubeResource extends EventResource {
+
+ private String videoId;
+
+ public String getVideoId() {
+ return videoId;
+ }
+
+ public void setVideoId(String videoId) {
+ this.videoId = videoId;
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/GravatarUtils.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,68 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.util;
+
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Utility methods for building Gravatar URLs.
+ *
+ * @author lucio
+ */
+public class GravatarUtils {
+
+ public static final String RATING_G = "g";
+ public static final String RATING_PG = "pg";
+ public static final String RATING_R = "r";
+ public static final String RATING_X = "x";
+ public static final String DEFAULT_IDENTICON = "identicon";
+ public static final String DEFAULT_MONSTERID = "monsterid";
+ public static final String DEFAULT_WAVATAR = "wavatar";
+
+ public static String hex(byte[] array) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < array.length; ++i) {
+ sb.append(Integer.toHexString((array[i] & 0xFF) |
0x100).substring(1, 3));
+ }
+ return sb.toString();
+ }
+
+ public static String md5Hex(String message) {
+ try {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ return hex(md.digest(message.getBytes("CP1252")));
+ } catch (NoSuchAlgorithmException e) {
+ } catch (UnsupportedEncodingException e) {
+ }
+ return null;
+ }
+
+ public static String getUrl(String email, Integer size, String rating,
String defaultAvatar) throws UnsupportedEncodingException {
+ StringBuilder sb = new
StringBuilder("
http://www.gravatar.com/avatar/");
+ sb.append(md5Hex(email)).append(".jpg");
+ Utilities.appendUrlParameter(sb, "s", size.toString(), true);
+ Utilities.appendUrlParameter(sb, "r", rating, true);
+ Utilities.appendUrlParameter(sb, "d", defaultAvatar, true);
+ return sb.toString();
+ }
+
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/JUGValidator.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,72 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.jugevents.core.util;
+
+
+import java.util.Arrays;
+
+import org.jugevents.core.po.JUG;
+import org.jugevents.core.util.mime.MimeUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.validation.Errors;
+import org.springframework.validation.Validator;
+
+/**
+ * Complex validation on the JUG data.
+ *
+ * @author lucio
+ */
+public class JUGValidator implements Validator {
+ private static final Logger logger =
LoggerFactory.getLogger(JUGValidator.class);
+ public static final String[] VALID_IMAGE_TYPES =
{"gif", "jpeg", "png"};
+ public static final String[] VALID_CERTIFICATE_TEMPLATE_TYPES =
{"pdf"};
+
+ public boolean supports(Class clazz) {
+ return JUG.class.isAssignableFrom(clazz);
+ }
+
+ public void validate(Object obj, Errors errors) {
+ JUG jug = (JUG) obj;
+ if (jug.getLogo() != null && jug.getLogo().length > 0) {
+ String mimeType =
+ MimeUtil.getMimeType(jug.getLogo());
+ String imgType = MimeUtil.getMinorComponent(mimeType);
+ if (Arrays.binarySearch(VALID_IMAGE_TYPES, imgType) < 0) {
+ logger.debug("An user tried to upload a logo of the wrong
type: "+imgType);
+ errors.rejectValue("logo", "JUG.logo.wrongContentType",
new Object[] {Arrays.toString(VALID_IMAGE_TYPES)}, "The type of the content
of the logo is wrong");
+ }
+ }
+ if (jug.getCertificateTemplate() != null &&
jug.getCertificateTemplate().length > 0) {
+ String mimeType =
+ MimeUtil.getMimeType(jug.getCertificateTemplate());
+ String tplType = MimeUtil.getMinorComponent(mimeType);
+ if (Arrays.binarySearch(VALID_CERTIFICATE_TEMPLATE_TYPES,
tplType) < 0) {
+ logger.debug("An user tried to upload a certificate
template of the wrong type: "+tplType);
+
errors.rejectValue("certificateTemplate", "JUG.certificate.wrongContentType",
new Object[] {Arrays.toString(VALID_CERTIFICATE_TEMPLATE_TYPES)}, "The type
of the content of the certificate template is wrong");
+ }
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/NotPassedEventsFilterFactory.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,41 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.util;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.TermRangeFilter;
+import org.hibernate.search.annotations.Factory;
+
+/**
+ * A factory for the Lucene filter producing only the not passed events.
+ *
+ * @author lucio
+ */
+public class NotPassedEventsFilterFactory {
+
+ static final DateFormat df = new SimpleDateFormat("yyyyMMdd");
+
+ @Factory
+ public Filter getFilter() {
+ return new TermRangeFilter("startDate", df.format(new Date()),
null, true, false);
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/TextFilterUtils.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,85 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.util;
+
+import java.io.StringWriter;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import net.java.textilej.parser.MarkupParser;
+import net.java.textilej.parser.builder.HtmlDocumentBuilder;
+import net.java.textilej.parser.markup.textile.TextileDialect;
+import org.apache.commons.lang.StringEscapeUtils;
+
+/**
+ * Utility for text filtering
+ *
+ * @author Lucio Benfante
+ */
+public class TextFilterUtils {
+
+ private static final Pattern replaceTypoCodePattern = Pattern.compile(
+ "<typo:code\\b([^>]*)>(.*?)</typo:code>", Pattern.DOTALL);
+ private static final Pattern replaceLangPattern = Pattern.compile(
+ "lang(?:\\s)?=(?:\\s)?([\"']+.*?[\"']+)");
+ private static final Pattern replaceIncompleteTypoCodePattern =
Pattern.compile(
+ "<typo:code>(.*?)</typo:code>", Pattern.DOTALL);
+ public static final String TEXTILE_FILTER = "textile";
+
+ public static String formatText(String txt, String fltr) {
+ String result = null;
+ if (txt != null) {
+ txt = filterTypoCode(txt);
+ if (TEXTILE_FILTER.equals(fltr)) {
+ StringWriter writer = new StringWriter();
+ HtmlDocumentBuilder builder = new
HtmlDocumentBuilder(writer);
+ // avoid the <html> and <body> tags
+ builder.setEmitAsDocument(false);
+ MarkupParser parser = new MarkupParser(new
TextileDialect());
+ parser.setBuilder(builder);
+ parser.parse(txt);
+ result = writer.toString();
+ } else {
+ result = escapeHtml(txt);
+ }
+ }
+ return result;
+ }
+
+ public static String filterTypoCode(String txt) {
+ String result = null;
+ Matcher matcher = replaceIncompleteTypoCodePattern.matcher(txt);
+ result = matcher.replaceAll("<pre name=\"code\"
class=\"xml\">$1</pre>");
+ matcher = replaceTypoCodePattern.matcher(result);
+ result = matcher.replaceAll("<pre name=\"code\"$1>$2</pre>");
+ matcher = replaceLangPattern.matcher(result);
+ result = matcher.replaceAll("class=$1");
+ return result;
+ }
+
+ public static String escapeHtml(String txt) {
+ return StringEscapeUtils.escapeHtml(txt);
+ }
+
+ public static String filterText(String text, String filter,
+ boolean escapeXml) {
+ // Only Textile for now
+ String result = TextFilterUtils.formatText(text,
TextFilterUtils.TEXTILE_FILTER);
+ return result;
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/mime/InvalidMagicMimeEntryException.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,40 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.util.mime;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * Extracted and modified from mime-util project under the Apache Software
Licence 2.0:
+ *
+ * <a
href="
http://sourceforge.net/projects/mime-util/">
http://sourceforge.net/projects/mime-util/</a>
+ */
+public class InvalidMagicMimeEntryException extends Exception {
+
+ private static final long serialVersionUID = -6705937358834408523L;
+
+ public InvalidMagicMimeEntryException() {
+ super("Invalid Magic Mime Entry: Unknown entry");
+ }
+
+ public InvalidMagicMimeEntryException(ArrayList mimeMagicEntry) {
+ super("Invalid Magic Mime Entry: " + mimeMagicEntry.toString());
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/mime/MagicMimeEntry.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,623 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.util.mime;
+
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.ArrayList;
+import java.util.Vector;
+
+
+/*
+ * A single MagicMime entry from the magic.mime file. This entry can
contain
+ * subentries; so it recursivelyincludes itself, if subentries are found.
+ * Basically this class represents a node in a simple n-ary tree
+ *
+ * TODO:
+ * o More commenting
+ * o Testing lelong, leshort, byte
+ * o Method stringWithEscapeSubstitutions to support more escape
sequences
+ * o Its a problem if the content has spaces (eg., "#!\ /bin/bash").
This needs
+ * to be fixed
+ * o Is any operation other equality on the contents supported?
+ * there are entries in the magic file where what seemed like a
greater
+ * than operator is supported. eg.,
+ * ">85 byte&0x01 >0 \b, zoomed"
+ * but such entries are commented out in magic.mime file.
+ *
+ * Extracted and modified from mime-util project under the Apache Software
Licence 2.0:
+ *
+ * <a
href="
http://sourceforge.net/projects/mime-util/">
http://sourceforge.net/projects/mime-util/</a>
+ *
+ */
+public class MagicMimeEntry {
+
+ public static final int STRING_TYPE = 1;
+ public static final int BELONG_TYPE = 2;
+ public static final int SHORT_TYPE = 3;
+ public static final int LELONG_TYPE = 4;
+ public static final int BESHORT_TYPE = 5;
+ public static final int LESHORT_TYPE = 6;
+ public static final int BYTE_TYPE = 7;
+ public static final int UNKNOWN_TYPE = 20;
+ private ArrayList subEntries = new ArrayList();
+ int checkBytesFrom;
+ int type;
+ String typeStr;
+ String content;
+ String mimeType;
+ String mimeEnc;
+ MagicMimeEntry parent;
+ boolean isBetween;
+
+ public MagicMimeEntry(ArrayList entries)
+ throws InvalidMagicMimeEntryException {
+
+ this(0, null, entries);
+ }
+
+ private MagicMimeEntry(int level, MagicMimeEntry parent, ArrayList
entries)
+ throws InvalidMagicMimeEntryException {
+
+ if (entries == null || entries.size() == 0) {
+ return;
+ }
+ try {
+ addEntry((String) entries.get(0));
+ } catch (Exception e) {
+ throw new InvalidMagicMimeEntryException(entries);
+ }
+ entries.remove(0);
+ this.parent = parent;
+ if (parent != null) {
+ parent.subEntries.add(this);
+ }
+
+ while (entries.size() > 0) {
+ int thisLevel = howManyGreaterThans((String) entries.get(0));
+ if (thisLevel > level) {
+ new MagicMimeEntry(thisLevel, this, entries);
+ } else {
+ break;
+ }
+ }
+ }
+
+ public String toString() {
+ return "MimeMagicType: " + checkBytesFrom + ", " + type + ", " +
content +
+ ", " + mimeType + ", " + mimeEnc;
+ }
+
+ public void traverseAndPrint(String tabs) {
+ // System.out.println(tabs + toString());
+ int len = subEntries.size();
+ for (int i = 0; i < len; i++) {
+ MagicMimeEntry me = (MagicMimeEntry) subEntries.get(i);
+ me.traverseAndPrint(tabs + "\t");
+ }
+ }
+
+ private int howManyGreaterThans(String aLine) {
+ if (aLine == null) {
+ return -1;
+ }
+ int i = 0;
+ int len = aLine.length();
+ while (i < len) {
+ if (aLine.charAt(i) == '>') {
+ i++;
+ } else {
+ break;
+ }
+ }
+ return i;
+ }
+
+
+ // There are problems with the magic.mime file. It seems that some of
the fields
+ // are space deliniated and not tab deliniated as defined in the spec.
+ // We will attempt to handle the case for space deliniation here so
that we can parse
+ // as much of the file as possible. Currently about 70 entries are
incorrect
+ void addEntry(String aLine) {
+ String trimmed = aLine.replaceAll("^>*", "");
+ String[] tokens = trimmed.split("\t");
+
+ // Now strip the empty entries
+ Vector v = new Vector();
+ for (int i = 0; i < tokens.length; i++) {
+ if (!"".equals(tokens[i])) {
+ v.add(tokens[i]);
+ }
+ }
+ tokens = new String[v.size()];
+ tokens = (String[]) v.toArray((String[]) tokens);
+
+ if (tokens.length > 0) {
+ String tok = tokens[0].trim();
+ try {
+ if (tok.startsWith("0x")) {
+ checkBytesFrom = Integer.parseInt(tok.substring(2),
16);
+ } else {
+ checkBytesFrom = Integer.parseInt(tok);
+ }
+ } catch (NumberFormatException e) {
+ // We could have a space delinitaed entry so lets try to
handle this anyway
+ addEntry(trimmed.replaceAll(" ", "\t"));
+ return;
+ }
+ }
+ if (tokens.length > 1) {
+ typeStr = tokens[1].trim();
+ type = getType(typeStr);
+ }
+ if (tokens.length > 2) {
+ // We don't trim the content
+ content = ltrim(tokens[2]);
+ content = stringWithEscapeSubstitutions(content);
+ }
+ if (tokens.length > 3) {
+ mimeType = tokens[3].trim();
+ }
+ if (tokens.length > 4) {
+ mimeEnc = tokens[4].trim();
+ }
+ }
+
+ private String ltrim(String s) {
+ for (int i = 0; i < s.length(); i++) {
+ if (s.charAt(i) != ' ') {
+ return s.substring(i);
+ }
+ }
+ return s;
+ }
+
+ private int getType(String tok) {
+ if (tok.startsWith("string")) {
+ return STRING_TYPE;
+ } else if (tok.startsWith("belong")) {
+ return BELONG_TYPE;
+ } else if (tok.equals("short")) {
+ return SHORT_TYPE;
+ } else if (tok.startsWith("lelong")) {
+ return LELONG_TYPE;
+ } else if (tok.startsWith("beshort")) {
+ return BESHORT_TYPE;
+ } else if (tok.startsWith("leshort")) {
+ return LESHORT_TYPE;
+ } else if (tok.equals("byte")) {
+ return BYTE_TYPE;
+ }
+
+ return UNKNOWN_TYPE;
+ }
+
+ public int getCheckBytesFrom() {
+ return checkBytesFrom;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public String getMimeType() {
+ return mimeType;
+ }
+
+ public String getMatch(byte[] content) throws IOException {
+ ByteBuffer buf = readBuffer(content);
+ if (buf == null) {
+ return null;
+ }
+ buf.position(0);
+ boolean matches = match(buf);
+ if (matches) {
+ int subLen = subEntries.size();
+ String myMimeType = getMimeType();
+ if (subLen > 0) {
+ String mtype = null;
+ for (int k = 0; k < subLen; k++) {
+ MagicMimeEntry me = (MagicMimeEntry) subEntries.get(k);
+ mtype = me.getMatch(content);
+ if (mtype != null) {
+ return mtype;
+ }
+ }
+ if (myMimeType != null) {
+ return myMimeType;
+ }
+ } else {
+ return myMimeType;
+ }
+ }
+
+ return null;
+ }
+
+ public String getMatch(RandomAccessFile raf) throws IOException {
+ ByteBuffer buf = readBuffer(raf);
+ if (buf == null) {
+ return null;
+ }
+ boolean matches = match(buf);
+ if (matches) {
+ String myMimeType = getMimeType();
+ if (subEntries.size() > 0) {
+ String mtype = null;
+ for (int i = 0; i < subEntries.size(); i++) {
+ MagicMimeEntry me = (MagicMimeEntry) subEntries.get(i);
+ mtype = me.getMatch(raf);
+ if (mtype != null) {
+ return mtype;
+ }
+ }
+ if (myMimeType != null) {
+ return myMimeType;
+ }
+ } else {
+ return myMimeType;
+ }
+ }
+
+ return null;
+ }
+
+ /*
+ * private methods for reading to local buffer
+ */
+ private ByteBuffer readBuffer(byte[] content) throws IOException {
+ int startPos = getCheckBytesFrom();
+ if (startPos > content.length) {
+ return null;
+ }
+
+ ByteBuffer buf;
+ switch (getType()) {
+ case MagicMimeEntry.STRING_TYPE: {
+ int len = getContent().length();
+ buf = ByteBuffer.allocate(len + 1);
+ buf.put(content, startPos, len);
+ break;
+ }
+
+ case MagicMimeEntry.SHORT_TYPE:
+ case MagicMimeEntry.LESHORT_TYPE:
+ case MagicMimeEntry.BESHORT_TYPE: {
+ buf = ByteBuffer.allocate(2);
+ buf.put(content, startPos, 2);
+ break;
+ }
+
+ case MagicMimeEntry.LELONG_TYPE:
+ case MagicMimeEntry.BELONG_TYPE: {
+ buf = ByteBuffer.allocate(4);
+ buf.put(content, startPos, 4);
+ break;
+ }
+
+ case MagicMimeEntry.BYTE_TYPE: {
+ buf = ByteBuffer.allocate(1);
+ buf.put(buf.array(), startPos, 1);
+ }
+
+ default: {
+ buf = null;
+ break;
+ }
+ }
+ return buf;
+ }
+
+ private ByteBuffer readBuffer(RandomAccessFile raf) throws IOException
{
+ int startPos = getCheckBytesFrom();
+ if (startPos > raf.length()) {
+ return null;
+ }
+ raf.seek(startPos);
+ ByteBuffer buf;
+ switch (getType()) {
+ case MagicMimeEntry.STRING_TYPE: {
+ int len = 0;
+ // Lets check if its a between test
+ int index = typeStr.indexOf(">");
+ if (index != -1) {
+ len = Integer.parseInt(typeStr.substring(index + 1,
+ typeStr.length() - 1));
+ isBetween = true;
+ } else {
+ len = getContent().length();
+ }
+ buf = ByteBuffer.allocate(len + 1);
+ raf.read(buf.array(), 0, len);
+ break;
+ }
+
+ case MagicMimeEntry.SHORT_TYPE:
+ case MagicMimeEntry.LESHORT_TYPE:
+ case MagicMimeEntry.BESHORT_TYPE: {
+ buf = ByteBuffer.allocate(2);
+ raf.read(buf.array(), 0, 2);
+ break;
+ }
+
+ case MagicMimeEntry.LELONG_TYPE:
+ case MagicMimeEntry.BELONG_TYPE: {
+ buf = ByteBuffer.allocate(4);
+ raf.read(buf.array(), 0, 4);
+ break;
+ }
+
+ case MagicMimeEntry.BYTE_TYPE: {
+ buf = ByteBuffer.allocate(1);
+ raf.read(buf.array(), 0, 1);
+ }
+
+ default: {
+ buf = null;
+ break;
+ }
+ }
+ return buf;
+ }
+
+ /*
+ * private methods used for matching
+ * differet types
+ */
+ private boolean match(ByteBuffer buf) throws IOException {
+ boolean matches = true;
+ switch (getType()) {
+ case MagicMimeEntry.STRING_TYPE: {
+ matches = matchString(buf);
+ break;
+ }
+
+ case MagicMimeEntry.SHORT_TYPE: {
+ matches = matchShort(buf, ByteOrder.BIG_ENDIAN, false,
+ (short) 0xFF);
+ break;
+ }
+
+ case MagicMimeEntry.LESHORT_TYPE:
+ case MagicMimeEntry.BESHORT_TYPE: {
+ ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+ if (getType() == MagicMimeEntry.LESHORT_TYPE) {
+ byteOrder = ByteOrder.LITTLE_ENDIAN;
+ }
+ boolean needMask = false;
+ short sMask = 0xFF;
+ int indx = typeStr.indexOf('&');
+ if (indx >= 0) {
+ sMask =
+ (short)
Integer.parseInt(typeStr.substring(indx + 3),
+ 16);
+ needMask = true;
+ } else if (getContent().startsWith("&")) {
+ sMask = (short)
Integer.parseInt(getContent().substring(3),
+ 16);
+ needMask = true;
+ }
+ matches = matchShort(buf, byteOrder, needMask, sMask);
+ break;
+ }
+
+ case MagicMimeEntry.LELONG_TYPE:
+ case MagicMimeEntry.BELONG_TYPE: {
+ ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+ if (getType() == MagicMimeEntry.LELONG_TYPE) {
+ byteOrder = ByteOrder.LITTLE_ENDIAN;
+ }
+ boolean needMask = false;
+ long lMask = 0xFFFFFFFF;
+ int indx = typeStr.indexOf('&');
+ if (indx >= 0) {
+ lMask = Long.parseLong(typeStr.substring(indx + 3),
16);
+ needMask = true;
+ } else if (getContent().startsWith("&")) {
+ lMask = Long.parseLong(getContent().substring(3), 16);
+ needMask = true;
+ }
+ matches = matchLong(buf, byteOrder, needMask, lMask);
+ break;
+ }
+
+ case MagicMimeEntry.BYTE_TYPE: {
+ matches = matchByte(buf);
+ }
+
+ default: {
+ matches = false;
+ break;
+ }
+ }
+ return matches;
+ }
+
+ private boolean matchString(ByteBuffer bbuf)
+ throws IOException {
+ if (isBetween) {
+ String buffer = new String(bbuf.array());
+ if (buffer.contains(getContent())) {
+ return true;
+ }
+ return false;
+ }
+ int read = getContent().length();
+ for (int j = 0; j < read; j++) {
+ if ((bbuf.get(j) & 0xFF) != getContent().charAt(j)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean matchByte(ByteBuffer bbuf)
+ throws IOException {
+ byte b = bbuf.get(0);
+ return b == getContent().charAt(0);
+ }
+
+ private boolean matchShort(ByteBuffer bbuf,
+ ByteOrder bo,
+ boolean needMask,
+ short sMask)
+ throws IOException {
+ bbuf.order(bo);
+ short got;
+ String testContent = getContent();
+ if (testContent.startsWith("0x")) {
+ got = (short) Integer.parseInt(testContent.substring(2), 16);
+ } else if (testContent.startsWith("&")) {
+ got = (short) Integer.parseInt(testContent.substring(3), 16);
+ } else {
+ got = (short) Integer.parseInt(testContent);
+ }
+
+ short found = bbuf.getShort();
+
+ if (needMask) {
+ found = (short) (found & sMask);
+ }
+
+ if (got != found) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private boolean matchLong(ByteBuffer bbuf,
+ ByteOrder bo,
+ boolean needMask,
+ long lMask)
+ throws IOException {
+ bbuf.order(bo);
+ long got;
+ String testContent = getContent();
+ if (testContent.startsWith("0x")) {
+ got = Long.parseLong(testContent.substring(2), 16);
+ } else if (testContent.startsWith("&")) {
+ got = Long.parseLong(testContent.substring(3), 16);
+ } else {
+ got = Long.parseLong(testContent);
+ }
+
+ long found = bbuf.getInt();
+
+ if (needMask) {
+ found = (short) (found & lMask);
+ }
+
+ if (got != found) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /*
+ * when bytes are read from the magic.mime file, the readers in java
will
+ * read escape sequences as regular bytes. That is, a sequence like
\040
+ * (represengint ' ' - space character) will be read as a backslash
+ * followed by a zero, four and zero -- 4 different bytes and not a
single
+ * byte representing space. This method parses the string and converts
+ * the sequence of bytes representing escape sequence to a single byte
+ *
+ * NOTE: not all regular escape sequences are added yet. add them, if
you
+ * don't find one here
+ */
+ private static String stringWithEscapeSubstitutions(String s) {
+ StringBuffer ret = new StringBuffer();
+ int len = s.length();
+ int indx = 0;
+ int c;
+ while (indx < len) {
+ c = s.charAt(indx);
+ if (c == '\n') {
+ break;
+ }
+
+ if (c == '\\') {
+ indx++;
+ if (indx >= len) {
+ ret.append((char) c);
+ break;
+ }
+
+ int cn = s.charAt(indx);
+
+ if (cn == '\\') {
+ ret.append('\\');
+ } else if (cn == ' ') {
+ ret.append(' ');
+ } else if (cn == 't') {
+ ret.append('\t');
+ } else if (cn == 'n') {
+ ret.append('\n');
+ } else if (cn == 'r') {
+ ret.append('\r');
+ } else if (cn >= '\60' && cn <= '\67') {
+ int escape = cn - '0';
+ indx++;
+ if (indx >= len) {
+ ret.append((char) escape);
+ break;
+ }
+ cn = s.charAt(indx);
+ if (cn >= '\60' && cn <= '\67') {
+ escape = escape << 3;
+ escape = escape | (cn - '0');
+
+ indx++;
+ if (indx >= len) {
+ ret.append((char) escape);
+ break;
+ }
+ cn = s.charAt(indx);
+ if (cn >= '\60' && cn <= '\67') {
+ escape = escape << 3;
+ escape = escape | (cn - '0');
+ } else {
+ indx--;
+ }
+ } else {
+ indx--;
+ }
+ ret.append((char) escape);
+ } else if (cn == 'x') {
+ int escape = Integer.parseInt(s.substring(indx + 1,
indx + 3), 16);
+ ret.append((char) escape);
+ indx+=2;
+ } else {
+ ret.append((char) cn);
+ }
+ } else {
+ ret.append((char) c);
+ }
+ indx++;
+ }
+ return new String(ret);
+ }
+}
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/mime/MimeUtil.java
Fri May 24 23:13:01 2013
@@ -0,0 +1,407 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jugevents.core.util.mime;
+
+
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.RandomAccessFile;
+import java.io.Reader;
+import java.nio.ByteOrder;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Utility class for detecting MIME type.
+ *
+ * Extracted and modified from mime-util project under the Apache Software
Licence 2.0:
+ *
+ * <a
href="
http://sourceforge.net/projects/mime-util/">
http://sourceforge.net/projects/mime-util/</a>
+ *
+ */
+public class MimeUtil {
+ private static final Logger logger =
+ LoggerFactory.getLogger(MimeUtil.class);
+
+ // private static final String [] magicMimeFileLocations =
{"/etc/magic.mime", "/usr/share/file/magic.mime"};
+ private static final String [] magicMimeFileLocations = {};
+
+ public static final String
UNKNOWN_MIME_TYPE="application/x-unknown-mime-type";
+
+
+ // the native byte order of the underlying OS. "BIG" or "little" Endian
+ private static ByteOrder nativeByteOrder = ByteOrder.nativeOrder();
+ private static Map mimeTypes;
+
+ private static ArrayList mMagicMimeEntries = new ArrayList();
+
+ // Get the native byte order of the OS on which you are running. It
will be either
+ // Big or little endiun
+ public static ByteOrder getNativeOrder() {
+ return MimeUtil.nativeByteOrder;
+ }
+
+ // Always use the magic.mime detection. Do not use the file extension
+ public static String getMimeType(byte[] content) {
+ String mimeType = null;
+ try {
+ mimeType = MimeUtil.getMagicMimeType(content);
+ }catch(Exception e) {
+ }finally {
+ if(mimeType == null) {
+ mimeType = UNKNOWN_MIME_TYPE;
+ }
+ }
+ return mimeType;
+ }
+
+ // Always use the magic.mime detection. Do not use the file extension
+ public static String getMimeType(File file) {
+ String mimeType = null;
+ try {
+ mimeType = MimeUtil.getMagicMimeType(file);
+ }catch(Exception e) {
+ }finally {
+ if(mimeType == null) {
+ mimeType = UNKNOWN_MIME_TYPE;
+ }
+ }
+ return mimeType;
+ }
+
+ // Determin the mime type of a file either from its name using
+ // file extension mapping and if that fails use the magig.mime rules.
+ // This requires that the name you pass is the FULL path to the file
+ // You are trying to detect or the magic.mime rule detection will fail
+ // as it will be unable to construct a File object without the path.
+ public static String getMimeType(String fname) {
+ String mimeType = null;
+ if(fname == null || "".equals(fname.trim())){
+ fname = "";
+ }
+ // Get the file extension
+ String ext = MimeUtil.getFileExtension(fname);
+ if(ext == null || "".equals(ext.trim())) {
+ // Lets sniff this as we cannot tell from the file extention
+ mimeType = MimeUtil.getMimeType(new File(fname));
+ } else {
+ // First try case sensitive
+ mimeType = (String)mimeTypes.get(ext);
+ if(mimeType == null || "".equals(mimeType.trim())) {
+ //try again case insensitive (lower case)
+ mimeType = (String)mimeTypes.get(ext.toLowerCase());
+ if(mimeType == null || "".equals(mimeType.trim())) {
+ // lets sniff it
+ mimeType = MimeUtil.getMimeType(new File(fname));
+ }
+ }
+ }
+ return mimeType;
+ }
+
+ // This doesn't actually detect a mime type. What it does do is give you
a best match
+ // for your requirements. Lets say you get the mime type from a file and
it returns
+ // a comma seperated list of mime types. You want to pass this back to a
browser as
+ // a particular format i.e. only one of the available formats, so you
pass in a list
+ // of formats you will accept i.e. from the browser HTTP accept header
and this method
+ // will try to determine which of the available mime types best suits
your needs.
+ public static String getPreferedMimeType(String wanted, String
canProvide) {
+
+ // The following is typical of what may be specified in the HTTP Accept
header.
+ // text/xml, application/xml, application/xhtml+xml, text/html;q=0.9,
text/plain;q=0.8, video/x-mng, image/png, image/jpeg, image/gif;q=0.2,
text/css, */*;q=0.1
+ // The quality parameter (q) indicates how well the user agent handles
the MIME type.
+ // A value of 1 indicates the MIME type is understood perfectly,
+ // and a value of 0 indicates the MIME type isn't understood at all.
+ // The reason the image/gif MIME type contains a quality parameter of
0.2, is to indicate that PNG is preferred over GIF
+ // if the server is using content negotiation to deliver either a PNG or
a GIF to user agents.
+ // Similarly, the text/html quality parameter has been lowered a little,
+ // to ensure that the XML MIME types are given in preference if content
negotiation is being used to serve an XHTML document.
+ if(wanted == null || wanted.trim().length() == 0) {
+ wanted = "";
+ }
+ String [] wantedArray = wanted.split(",");
+ String [] canProvideArray = canProvide.split(",");
+ if(canProvideArray.length == 1) {
+ // this is all we have to offer
+ return canProvideArray[0].trim();
+ }
+ // Else lets check the rest.
+
+ // TODO. Improve the matching. We need to check for the QoS part to
determine the
+ // best match. See note above
+ for(int i = 0; i < wantedArray.length; i++) {
+ if(wantedArray[i].trim().equals("*/*")) {
+ return canProvideArray[0].trim();
+ }
+ for(int j = 0; j < canProvideArray.length; j++) {
+
if(wantedArray[i].trim().compareToIgnoreCase(canProvideArray[j].trim()) ==
0) {
+ return wantedArray[i].trim();
+ }
+ }
+ }
+ // Assume a wanted type of '*/*' exists and just return the first
canProvide type
+ return canProvideArray[0].trim();
+ }
+
+
+ // Initialise the class in preperation for mime type detection
+ static {
+ mimeTypes = new Properties();
+ // Load the file extension mappings from the internal property file and
then
+ // from the custom property file if it can be found on the classpath
+ try {
+ // Load the default supplied mime types
+
((Properties)mimeTypes).load(MimeUtil.class.getClassLoader().getResourceAsStream("it/jugpadova/util/mime/mime-types.properties"));
+ // Load any classpath provided mime types that either extend or
override the default mime types
+ InputStream is =
MimeUtil.class.getClassLoader().getResourceAsStream("mime-types.properties");
+ if(is != null) {
+ try {
+ Properties props = new Properties();
+ props.load(is);
+ if(props.size() > 0) {
+
logger.info("Customisations of Mime Types are available");
+ mimeTypes.putAll(props);
+ }
+ }finally {
+ if(is != null) {
+ is.close();
+ }
+ }
+ } else {
+
logger.info("No Customisation or Mime Types available.");
+ }
+ } catch (IOException ignore) {}
+
+ // Now parse and initialise the magic.mime rules
+ InputStream is = null;
+ // Parse any customised magic.mime file first. This overrides the unix
version
+ // as any rules you define will always match before the original.
+ is = MimeUtil.class.getClassLoader().getResourceAsStream("magic.mime");
+ if(is != null) {
+ try {
+ parse(new InputStreamReader(is));
+ }catch(Exception e) {
+ e.printStackTrace();
+ // We just won't have any customisations
+ }finally {
+ if(is != null) {
+ try {
+ is.close();
+ }catch(Exception e) {} // ignore
+ }
+ // Set to null for the next search
+ is = null;
+ }
+ }
+
+ // Parse the UNIX magic(5) magic.mime file.
+ // This is used should the mime type not be decernable from the extension
+ // i.e. the file has no extension
+ try {
+ boolean found = false;
+ for(int i = 0; i< magicMimeFileLocations.length; i++) {
+ File f = new File(magicMimeFileLocations[i]);
+ if(f.exists()) {
+ is = new FileInputStream(f);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ // Use the magic.mime that we ship
+ is =
MimeUtil.class.getClassLoader().getResourceAsStream("it/jugpadova/util/mime/magic.mime");
+ }
+ parse(new InputStreamReader(is));
+ }catch(Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ if(is != null) {
+ try {
+ is.close();
+ }catch(Exception e) {} // ignore
+ }
+ }
+ }
+
+ public static void main(String [] args) throws IOException {
+ System.out.println(mMagicMimeEntries);
+
+ File dir = new File(".");
+ File [] f = dir.listFiles();
+ for(int i = 0; i < f.length; i++) {
+ System.out.println("file : " + f[i].getCanonicalPath() + " :
mimeType : " + MimeUtil.getMimeType(f[i].getCanonicalPath()));
+ }
+
+
+ System.out.println(MimeUtil.getMajorComponent("application/abcd"));
+ System.out.println(MimeUtil.getMajorComponent("application"));
+ System.out.println(MimeUtil.getMajorComponent("/application/abcd"));
+ System.out.println(MimeUtil.getMajorComponent(""));
+ System.out.println(MimeUtil.getMajorComponent(null));
+
+ System.out.println(MimeUtil.getMinorComponent("application/abcd"));
+ System.out.println(MimeUtil.getMinorComponent("application"));
+ System.out.println(MimeUtil.getMinorComponent("/application/abcd"));
+ System.out.println(MimeUtil.getMinorComponent(""));
+ System.out.println(MimeUtil.getMinorComponent(null));
+
+ }
+
+ // Parse the magic.mime file
+ private static void parse(Reader r) throws IOException {
+ BufferedReader br = new BufferedReader(r);
+ String line;
+ ArrayList sequence = new ArrayList();
+
+ line = br.readLine();
+ while (true) {
+ if (line == null) {
+ break;
+ }
+ line = line.trim();
+ if (line.length() == 0 || line.charAt(0) == '#') {
+ line = br.readLine();
+ continue;
+ }
+ sequence.add(line);
+
+ // read the following lines until a line does not begin
with '>' or EOF
+ while(true) {
+ line = br.readLine();
+ if(line == null) {
+ addEntry(sequence);
+ sequence.clear();
+ break;
+ }
+ line = line.trim();
+ if (line.length() == 0 || line.charAt(0) == '#') {
+ continue;
+ }
+ if(line.charAt(0) != '>') {
+ addEntry(sequence);
+ sequence.clear();
+ break;
+ }
+ sequence.add(line);
+ }
+
+ }
+ if(!sequence.isEmpty()) {
+ addEntry(sequence);
+ }
+ }
+
+ private static void addEntry(ArrayList aStringArray) {
+ try {
+ MagicMimeEntry magicEntry = new MagicMimeEntry(aStringArray);
+ mMagicMimeEntries.add(magicEntry);
+ } catch (InvalidMagicMimeEntryException e) {
+ // Continue on but lets print an exception so people can see there is a
problem
+ e.printStackTrace();
+ }
+ }
+
+ private static String getMagicMimeType(File f) throws IOException {
+ if(f.isDirectory()) {
+ return "application/directory";
+ }
+ int len = mMagicMimeEntries.size();
+ RandomAccessFile raf = new RandomAccessFile(f, "r");
+ for (int i=0; i < len; i++) {
+ MagicMimeEntry me = (MagicMimeEntry) mMagicMimeEntries.get(i);
+ String mtype = me.getMatch(raf);
+ if (mtype != null) {
+ return mtype;
+ }
+ }
+ return null;
+ }
+
+ private static String getMagicMimeType(byte[] content) throws
IOException {
+ int len = mMagicMimeEntries.size();
+ for (int i=0; i < len; i++) {
+ MagicMimeEntry me = (MagicMimeEntry) mMagicMimeEntries.get(i);
+ String mtype = me.getMatch(content);
+ if (mtype != null) {
+ return mtype;
+ }
+ }
+ return null;
+ }
+
+ // Utility method to get the major part of a mime type
+ // i.e. the bit before the '/' character
+ public static String getMajorComponent(String mimeType) {
+ if(mimeType == null) {
+ return "";
+ }
+ int offset = mimeType.indexOf("/");
+ if(offset == -1) {
+ return mimeType;
+ } else {
+ return mimeType.substring(0, offset);
+ }
+ }
+
+ // Utility method to get the minor part of a mime type
+ // i.e. the bit after the '/' character
+ public static String getMinorComponent(String mimeType) {
+ if(mimeType == null) {
+ return "";
+ }
+ int offset = mimeType.indexOf("/");
+ if(offset == -1) {
+ return mimeType;
+ } else {
+ return mimeType.substring(offset+1);
+ }
+ }
+
+ // Utility method that gets the extension of a file from its name if
it has one
+ public static String getFileExtension(File file) {
+ try {
+ return MimeUtil.getFileExtension(file.getCanonicalPath());
+ }catch(IOException e) {
+ return "";
+ }
+ }
+
+ // Utility method that gets the extension of a file from its name if
it has one
+ public static String getFileExtension(String fileName) {
+ if (fileName == null || fileName.lastIndexOf(".") < 0) {
+ return "";
+ }
+ String extension = fileName.substring(fileName.lastIndexOf(".") + 1);
+ // Could be that the path actually had a '.' in it so lets check
+ if(extension.contains(File.separator)) {
+ extension = "";
+ }
+ return extension;
+ }
+}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/ArchiveVideoResourceDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.ArchiveVideoResource;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-@Dao(entity = ArchiveVideoResource.class)
-public interface ArchiveVideoResourceDao extends
GenericDao<ArchiveVideoResource, Long> {
-}
=======================================
--- /jugevents/jugevents-web/src/main/java/it/jugpadova/dao/EventDao.java
Fri Mar 8 18:53:49 2013
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.Event;
-
-import java.util.Date;
-import java.util.List;
-import org.lambico.dao.generic.Compare;
-import org.lambico.dao.generic.CompareType;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-@Dao(entity = Event.class)
-public interface EventDao extends GenericDao<Event, Long> {
-
- List<Event> findByLocation(String location);
-
- List<Event> findCurrentEvents();
-
- List<Event> findEventByPartialLocation(String location);
-
- List<Event> findEventByPartialLocationAndJugOwner(String
partialLocation,
- String jugOwner);
-
- List<Event> findUpcomingEvents(Date notAfter);
-
- List<Event> findNewEvents(Date notBefore);
-
- /**
- * Retrieves all events by partial title.
- * @param partialTitle
- * @return
- */
- List<Event> findByTitle(@Compare(CompareType.ILIKE) String
partialTitle);
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/EventLinkDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.EventLink;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-@Dao(entity = EventLink.class)
-public interface EventLinkDao extends GenericDao<EventLink, Long> {
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/EventResourceDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.EventResource;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-@Dao(entity = EventResource.class)
-public interface EventResourceDao extends GenericDao<EventResource, Long> {
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/FlickrResourceDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.FlickrResource;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-@Dao(entity = FlickrResource.class)
-public interface FlickrResourceDao extends GenericDao<FlickrResource,
Long> {
-}
=======================================
--- /jugevents/jugevents-web/src/main/java/it/jugpadova/dao/JUGDao.java Thu
Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.JUG;
-
-import java.util.List;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-/**
- * @author Enrico Giurin
- *
- */
-@Dao(entity = JUG.class)
-public interface JUGDao extends GenericDao<JUG, Long> {
-
- JUG findByName(String jugName);
-
- JUG findByICName(String jugName);
-
- List<JUG> findByPartialName(String s);
-
- List<JUG> findByPartialJugNameAndCountry(String partialName,
- String partialCountryEnglishName);
-
- List<JUG> findByNameAndCountryEN(String name, String
countryEnglishName);
-
- List<JUG> findByPartialJugNameAndCountryAndContinent(String
partialName,
- String partialCountry, String partialContinent);
-
- JUG findByInternalFriendlyName(String internalFriendlyName);
-}
=======================================
--- /jugevents/jugevents-web/src/main/java/it/jugpadova/dao/JuggerDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.Jugger;
-
-import java.util.List;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-/**
- * @author Enrico Giurin <
enrico...@gmail.com>
- * @author Lucio Benfante <
lucio.b...@gmail.com>
- */
-@Dao(entity = Jugger.class)
-public interface JuggerDao extends GenericDao<Jugger, Long> {
-
- public List<Jugger> findByPartialJugNameAndCountryAndContinent(
- String juggerName, String countryLocalName, String continent);
-
- Jugger searchByUsername(String username);
-
- Jugger findByUsernameAndConfirmationCode(String username, String
confirmationCode);
-
- Jugger findByUsernameAndChangePasswordCode(String username, String
changePasswordCode);
-
- Jugger findByEmail(String email);
-
- List<Jugger> findAllOrderByUsername();
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/LinkedEventDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.LinkedEvent;
-
-import java.util.List;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-@Dao(entity = LinkedEvent.class)
-public interface LinkedEventDao extends GenericDao<LinkedEvent, Long> {
-
- public List<LinkedEvent> findExposedEvents();
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/ParticipantDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.Participant;
-
-import java.util.List;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-@Dao(entity = Participant.class)
-public interface ParticipantDao extends GenericDao<Participant, Long> {
-
- List<Participant> findByEmailAndConfirmationCodeAndConfirmed(String
email,
- String confirmationCode, Boolean confirmed);
-
- Participant findByEmailAndConfirmationCode(String email,
- String confirmationCode);
-
- List<Participant> findConfirmedParticipantsByEventId(Long id);
-
- List<Participant>
findConfirmedParticipantsByEventIdOrderByLastNameAndFirstName(
- Long id);
-
- List<Participant> findNotConfirmedParticipantsByEventId(Long id);
-
- List<Participant> findCancelledParticipantsByEventId(Long id);
-
- List<Participant> findParticipantByEmailAndEventId(String email,
- Long eventId);
-
- List<Participant> findParticipantsByEventId(Long eventId);
-
- List<Participant> findPresentParticipantsByEventId(Long eventId);
-
- List<Participant> findWinningParticipantsByEventId(Long eventId);
-
- List<Participant> findNonwinningParticipantsByEventId(Long eventId);
-
- List<Participant> findParticipantsToBeReminded();
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/SlideShareResourceDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.SlideShareResource;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-@Dao(entity = SlideShareResource.class)
-public interface SlideShareResourceDao extends
GenericDao<SlideShareResource, Long> {
-}
=======================================
--- /jugevents/jugevents-web/src/main/java/it/jugpadova/dao/SpeakerDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import java.util.List;
-
-import it.jugpadova.po.Event;
-import it.jugpadova.po.Speaker;
-import org.lambico.dao.generic.Compare;
-import org.lambico.dao.generic.CompareType;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-/**
- * DAO associated to Speaker po.
- * @author Enrico Giurin
- *
- */
-@Dao(entity = Speaker.class)
-public interface SpeakerDao extends GenericDao<Speaker, Long> {
-
- /**
- * Retrieves all the events in which the speaker, identified by
partial email, has been teacher.
- * @param speakerEmail
- * @return
- */
- List<Event> findEventsByPartialSpeakerEmail(String speakerEmail);
-
- /**
- * Retrieves all the speakers which have presented in events
- * identified by partial eventTitle.
- * @param eventTitle
- * @return
- */
- List<Speaker> findSpeakersByPartialEventTitle(String eventTitle);
-
- /**
- * Retrieves all the speakers identified by a partial resume.
- * @param resume
- * @return
- */
- List<Speaker> findByResume(@Compare(CompareType.ILIKE) String resume);
-
- List<Speaker> allByEvent(Long id);
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/dao/YouTubeResourceDao.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.dao;
-
-import it.jugpadova.po.YouTubeResource;
-import org.lambico.dao.generic.Dao;
-import org.lambico.dao.generic.GenericDao;
-
-@Dao(entity = YouTubeResource.class)
-public interface YouTubeResourceDao extends GenericDao<YouTubeResource,
Long> {
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/ArchiveVideoResource.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.po;
-
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-
-/**
- * A SlideShare (
www.slideshare.net) resource.
- *
- * @author Lucio Benfante (<a
href="
lucio.b...@jugpadova.it">
lucio.b...@jugpadova.it</a>)
- * @version $Revision$
- */
-@Entity
-@DiscriminatorValue("ArchiveVideo")
-public class ArchiveVideoResource extends EventResource {
- private String flashVideoUrl;
- private String detailsUrl;
-
- public String getDetailsUrl() {
- return detailsUrl;
- }
-
- public void setDetailsUrl(String detailsUrl) {
- this.detailsUrl = detailsUrl;
- }
-
- public String getFlashVideoUrl() {
- return flashVideoUrl;
- }
-
- public void setFlashVideoUrl(String flashVideoUrl) {
- this.flashVideoUrl = flashVideoUrl;
- }
-
-}
=======================================
--- /jugevents/jugevents-web/src/main/java/it/jugpadova/po/Event.java Sun
May 19 10:58:10 2013
+++ /dev/null
@@ -1,512 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package it.jugpadova.po;
-
-import it.jugpadova.blo.FilterBo;
-import it.jugpadova.util.NotPassedEventsFilterFactory;
-import it.jugpadova.util.Utilities;
-import java.io.Serializable;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Embedded;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import
javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-
-import org.hibernate.search.annotations.DateBridge;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.FullTextFilterDef;
-import org.hibernate.search.annotations.FullTextFilterDefs;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Resolution;
-import org.hibernate.search.annotations.Store;
-import org.hibernate.validator.constraints.NotBlank;
-
-/**
- * An event.
- *
- * @author Lucio Benfante
- */
-@Entity
-@Indexed
-@NamedQueries(value = {
- @NamedQuery(name = "Event.findCurrentEvents", query =
- "from Event e where e.startDate >= current_date()"),
- @NamedQuery(name = "Event.findEventByPartialLocation", query =
- "from Event e where lower(e.location) like lower(?) order by
e.location"),
- @NamedQuery(name = "Event.findEventByPartialLocationAndJugOwner",
- query =
- "from Event e where lower(e.location) like lower(?) and
e.jugOwner.name = ? order by e.location"),
- @NamedQuery(name = "Event.findUpcomingEvents",
- query =
- "from Event e where e.startDate >= current_date() and e.startDate <= ?
order by e.startDate"),
- @NamedQuery(name = "Event.findNewEvents",
- query =
- "from Event e where e.startDate >= current_date() and e.creationDate
>= ? order by e.startDate")
-})
-@FullTextFilterDefs({
- @FullTextFilterDef(name = "notPassedEvents", impl =
- NotPassedEventsFilterFactory.class)
-})
-public class Event implements org.lambico.po.hibernate.Entity,
Serializable {
-
- protected Long id;
- private String title;
- private Date startDate;
- private String startTime;
- private Date endDate;
- private String endTime;
- private String location;
- private String directions;
- private String description;
- private String filter = "Textile";
- private JUG jugOwner;
-
- private Date creationDate;
- private Registration registration;
- private List<EventResource> eventResources;
- private List<Speaker> speakers = new ArrayList<Speaker>();
- private byte[] badgeTemplate;
- private Date reminderDate;
- private boolean activeReminder = false;
- public final static int NUM_OF_DAYS_REMINDER_BEFORE_EVENT = 2;
-
- /**
- * Get the entity id.
- *
- * @return the entity id.
- */
- @Id
- @DocumentId
- @GeneratedValue(strategy = GenerationType.AUTO)
- public Long getId() {
- return
this.id;
- }
-
- public void setId(Long id) {
-
this.id = id;
- }
-
-
-
-
- @Column(length = 1024)
- @Field(index = Index.TOKENIZED, store = Store.NO)
- public String getDirections() {
- return directions;
- }
-
- public void setDirections(String directions) {
- this.directions = directions;
- }
-
- public String getFilter() {
- return filter;
- }
-
- public void setFilter(String filter) {
- this.filter = filter;
- }
- private List<Participant> participants;
-
- /** Creates a new instance of Event */
- public Event() {
- }
-
- @Field(index = Index.TOKENIZED, store = Store.NO)
- @NotBlank
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- @Temporal(value = TemporalType.DATE)
- @Field(index = Index.UN_TOKENIZED, store = Store.YES)
- @DateBridge(resolution = Resolution.DAY)
- @NotNull
- public Date getStartDate() {
- return startDate;
- }
-
- public void setStartDate(Date startDate) {
- this.startDate = startDate;
- }
-
- public String getStartTime() {
- return startTime;
- }
-
- public void setStartTime(String startTime) {
- this.startTime = startTime;
- }
-
- @Temporal(value = TemporalType.DATE)
- public Date getEndDate() {
- return endDate;
- }
-
- public void setEndDate(Date endDate) {
- this.endDate = endDate;
- }
-
- public String getEndTime() {
- return endTime;
- }
-
- public void setEndTime(String endTime) {
- this.endTime = endTime;
- }
-
- @Field(index = Index.TOKENIZED, store = Store.NO)
- @NotBlank
- public String getLocation() {
- return location;
- }
-
- public void setLocation(String location) {
- this.location = location;
- }
-
- @Lob
- @Field(index = Index.TOKENIZED, store = Store.NO)
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- @OneToMany(mappedBy = "event", cascade = {CascadeType.ALL})
- public List<Participant> getParticipants() {
- return participants;
- }
-
- public void setParticipants(List<Participant> participants) {
- this.participants = participants;
- }
-
- public void addParticipant(Participant participant) {
- if (this.participants == null) {
- this.participants =
- new LinkedList<Participant>();
- }
- this.participants.add(participant);
- participant.setEvent(this);
- }
-
- @Temporal(value = TemporalType.TIMESTAMP)
- public Date getCreationDate() {
- return creationDate;
- }
-
- public void setCreationDate(Date creationDate) {
- this.creationDate = creationDate;
- }
-
- @Embedded
- @Valid
- public Registration getRegistration() {
- return registration;
- }
-
- public void setRegistration(Registration registration) {
- this.registration = registration;
- }
-
- @OneToMany(mappedBy = "event", cascade = {CascadeType.ALL})
- public List<EventResource> getEventResources() {
- return eventResources;
- }
-
- public void setEventResources(List<EventResource> eventResources) {
- this.eventResources = eventResources;
- }
-
- @OneToMany(mappedBy = "event", orphanRemoval = true, cascade =
CascadeType.ALL)
- public List<Speaker> getSpeakers() {
- if (this.speakers == null) {
- this.speakers = new ArrayList<Speaker>();
- }
- return speakers;
- }
-
- public void setSpeakers(List<Speaker> speakers) {
- this.speakers = speakers;
- }
-
- @Lob
- @Basic(fetch = FetchType.LAZY)
- public byte[] getBadgeTemplate() {
- return badgeTemplate;
- }
-
- public void setBadgeTemplate(byte[] badgeTemplate) {
- this.badgeTemplate = badgeTemplate;
- }
-
- @Transient
- public int getNumberOfParticipants() {
- int result = 0;
- if (getParticipants() != null) {
- for (Participant p : getParticipants()) {
- if (p.hasValidRegistration()) {
- result++;
- }
- }
- }
- return result;
- }
-
- @Transient
- public String getFilteredDirections() {
- String filteredDirections =
- FilterBo.filterText(this.getDirections(), this.getFilter(),
- false);
- return filteredDirections;
- }
-
- @Transient
- public String getFilteredDescription() {
- String filteredDescription =
- FilterBo.filterText(this.getDescription(),
this.getFilter(),
- false);
- return filteredDescription;
- }
-
- /**
- * Decide if the registration is open or not, based on the event data
- *
- * @param event The event
- * @return true if the registration is open. False, otherwise.
- */
- @Transient
- public boolean getRegistrationOpen() {
- boolean result = false;
- final Registration reg = this.getRegistration();
- if (thereAreNoRegistrationRules(reg)) { // old way
- result = todayIsBeforeTheEndOfTheStartDay();
- } else {
- if (reg.getEnabled().booleanValue()) {
- if (reg.getManualActivation() != null) {
- result = reg.getManualActivation();
- } else {
- // TODO complete with other rules
- if (partecipantsAreUnderTheLimit(reg) &&
todayIsInTheRegistrationInterval(
- reg)) {
- result = true;
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Return the name of the hosting organization.
- *
- * @return The name of the hosting organization. Or "" if there is no
hosting organization.
- */
- @Transient
- public String getHostingOrganizationName() {
- String result = "";
- if (this.getJugOwner() != null) {
- result = this.getJugOwner().getName();
- }
- return result;
- }
-
- /**
- * Return the URL of the hosting organization.
- *
- * @return The URL of the hosting organization. Or "" if there is no
hosting organization URL/Web site.
- */
- @Transient
- public String getHostingOrganizationUrl() {
- String result = "";
- if (this.getJugOwner() != null) {
- result = this.getJugOwner().getWebSiteUrl();
- }
- return result;
- }
-
- private boolean partecipantsAreUnderTheLimit(final Registration reg) {
- return reg.getMaxParticipants() == null ||
this.getNumberOfParticipants() < reg.
- getMaxParticipants().longValue();
- }
-
- public boolean todayIsBeforeTheEndOfTheStartDay() {
- return Utilities.todayIsBeforeDate(this.startDate);
- }
-
- private boolean thereAreNoRegistrationRules(final Registration reg) {
- return reg == null || (reg != null && reg.getEnabled() &&
reg.getManualActivation() == null && reg.
- getStartRegistration()
- == null && reg.getEndRegistration() == null &&
reg.getMaxParticipants() == null);
- }
-
- private boolean todayIsInTheRegistrationInterval(Registration reg) {
- boolean result = true;
- Date now = new Date();
- if ((reg.getStartRegistration() != null &&
reg.getStartRegistration().
- compareTo(now) > 0) || (reg.getEndRegistration() != null
&& reg.getEndRegistration().
- compareTo(now) < 0) || (reg.getEndRegistration() == null
- && !todayIsBeforeTheEndOfTheStartDay())) {
- result = false;
- }
- return result;
- }
-
- public void setReminderDate(Date reminderDate) {
- this.reminderDate = reminderDate;
- }
-
- @Temporal(javax.persistence.TemporalType.TIMESTAMP)
- public Date getReminderDate() {
- return reminderDate;
- }
-
- /**
- * Returns a convenient subject for the mail relating to the event
itself.
- * Possible usages are for jug contact's email and speakers.
- * The value is encoded.
- * @return
- */
- @Transient
- public String getSubjectForEmailContact() throws
UnsupportedEncodingException {
- return URLEncoder.encode(this.getTitle(), "UTF-8");
- }
-
- /**
- * This method is called from the EventEditController to calculate
- * the date of reminder date.
- * Currently reminderDate corresponds to 2 days earlier the event
- * start date.
- */
- public void updateReminderDate() {
- if (this.getActiveReminder()) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(this.getStartDate());
- gc.add(GregorianCalendar.DAY_OF_YEAR,
-NUM_OF_DAYS_REMINDER_BEFORE_EVENT);
- this.setReminderDate(gc.getTime());
- } else {
- this.setReminderDate(null);
- }
-
- }
-
- @Transient
- public boolean getActiveReminder() {
- return activeReminder;
- }
-
- public void setActiveReminder(boolean activeReminder) {
- this.activeReminder = activeReminder;
- }
-
- @Transient
- public boolean isEventInThePast() {
- return !Utilities.todayIsBeforeDate(this.endDate);
- }
-
- /**
- * Default implementation of the equals method.
- * It return true if the objects are of the same type and have
- * the same id.
- *
- * @param obj The object to compare with this
- * @return true if the objects are equals
- */
- @Override
- public boolean equals(final Object obj) {
- boolean result = false;
- if (obj != null) {
- String className = obj.getClass().getName();
- if (className.indexOf("$$EnhancerByCGLIB$$") > 0) {
- className = className.substring(0,
className.indexOf("$$EnhancerByCGLIB$$"));
- }
- if (this.getClass().getName().equals(className)) {
- if (this.getId() != null && this.getId().equals(((Event)
obj).getId())) {
- result = true;
- }
- }
- }
- return result;
- }
-
- /**
- * Default implementation of the hashcode method for an Entity.
- * It return the hascode of the Id, if the Id is not null.
- * It return the hascode of the Object, if the Id is null.
- *
- * @return The hashcode of the entity instance.
- */
- @Override
- public int hashCode() {
- int result;
- if (this.getId() != null) {
- result = this.getId().hashCode();
- } else {
- result = super.hashCode();
- }
- return result;
- }
-
- @Override
- public String toString() {
- return this.getClass().getName() + "[id=" +
this.id + "]";
- }
- @ManyToOne
- public JUG getJugOwner() {
- return jugOwner;
- }
-
- public void setJugOwner(JUG jugOwner) {
- this.jugOwner = jugOwner;
- }
-
-
-
-}
=======================================
--- /jugevents/jugevents-web/src/main/java/it/jugpadova/po/EventLink.java
Thu Mar 31 09:40:30 2011
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.po;
-
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-import javax.persistence.Transient;
-import org.apache.commons.lang.StringUtils;
-
-/**
- * A web link resource.
- *
- * @author Lucio Benfante (<a
href="
lucio.b...@jugpadova.it">
lucio.b...@jugpadova.it</a>)
- * @version $Revision$
- */
-@Entity
-@DiscriminatorValue("Link")
-public class EventLink extends EventResource {
- private String url;
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- @Transient
- public String getAbbreviatedUrl() {
- return StringUtils.abbreviate(url, 40);
- }
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/EventResource.java
Thu Mar 31 08:27:26 2011
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.po;
-
-import javax.persistence.Entity;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.ManyToOne;
-import org.lambico.po.hibernate.EntityBase;
-
-/**
- * Resource associated to an event.
- *
- * @author lucio
- */
-@Entity
-@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
-public abstract class EventResource extends EntityBase {
- private String description;
- private Event event;
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- @ManyToOne
- public Event getEvent() {
- return event;
- }
-
- public void setEvent(Event event) {
- this.event = event;
- }
-
-}
=======================================
---
/jugevents/jugevents-web/src/main/java/it/jugpadova/po/FlickrResource.java
Thu Mar 31 09:40:30 2011
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.po;
-
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-
-/**
- * A Flickr (
www.flickr.com) resource.
- *
- * @author Lucio Benfante (<a
href="
lucio.b...@jugpadova.it">
lucio.b...@jugpadova.it</a>)
- * @version $Revision$
- */
-@Entity
-@DiscriminatorValue("Flickr")
-public class FlickrResource extends EventResource {
- private String tag;
-
- public String getTag() {
- return tag;
- }
-
- public void setTag(String tag) {
- this.tag = tag;
- }
-
-}
=======================================
--- /jugevents/jugevents-web/src/main/java/it/jugpadova/po/JUG.java Thu Mar
31 09:40:30 2011
+++ /dev/null
@@ -1,213 +0,0 @@
-/**
- * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
- *
- * This file is part of JUG Events Web Application.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package it.jugpadova.po;
-
-import it.jugpadova.util.JUGValidator;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Transient;
-import javax.validation.Valid;
-import org.apache.commons.lang.StringUtils;
-import org.hibernate.validator.constraints.Email;
-import org.hibernate.validator.constraints.NotBlank;
-import org.lambico.po.hibernate.EntityBase;
-
-import org.parancoe.plugins.world.Country;
-
-/**
- * Represents Java User Group informations.
- * @author Enrico Giurin
- *
- */
-@Entity
-@NamedQueries(value = {@NamedQuery(name = "JUG.findByPartialName", query =
-"from JUG j where upper(
j.name) like upper(?) order by
j.name asc"),
@NamedQuery(name =
-"JUG.findByPartialJugNameAndCountry", query =
-"from JUG jug where upper(
jug.name) like upper(?) and
upper(jug.country.englishName) like upper(?) order by
jug.name asc"),
@NamedQuery(name =
-"JUG.findByNameAndCountryEN", query =
-"from JUG jug where upper(
jug.name) = upper(?) and
upper(jug.country.englishName) = upper(?) order by
jug.name asc"),
-@NamedQuery(name =
-"JUG.findByICName", query =
-"from JUG jug where upper(
jug.name) = upper(?) order by
jug.name asc"),
@NamedQuery(name =
-"JUG.findByPartialJugNameAndCountryAndContinent", query =
-"from JUG j where upper(
j.name) like upper(?) and
upper(j.country.localName) like upper(?) and
upper(
j.country.continent.name) like upper(?) order by
j.name asc")
-})
-// TODO V3: reimplement JUG validator. @Validator(value =
JUGValidator.class)
-public class JUG extends EntityBase {
-
- private static final long serialVersionUID = -40063909128565029L;
- /**
- * JUG name
- */
- private String name;
- private Country country;
- private String webSite;
- private Double latitude;
- private Double longitude;
- private String infos;
- private Boolean modifiedKmlData;
- private byte[] logo;
- private String contactName;
- private String contactEmail;
- private String timeZoneId;
- private byte[] certificateTemplate;
- private String internalFriendlyName;
-
- @NotBlank
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
-
this.name = name;
- }
-
- @ManyToOne
- @Valid
- public Country getCountry() {
- return country;
- }
-
- public void setCountry(Country country) {
- this.country = country;
- }
-
- public Double getLatitude() {
- return latitude;
- }
-
- public void setLatitude(Double latitude) {
- this.latitude = latitude;
- }
-
- public Double getLongitude() {
- return longitude;
- }
-
- public void setLongitude(Double longitude) {
- this.longitude = longitude;
- }
-
- public String getWebSite() {
- return webSite;
- }
-
- public void setWebSite(String webSite) {
- this.webSite = webSite;
- }
-
- @Column(length = 1024)
- public String getInfos() {
- return infos;
- }
-
- public void setInfos(String infos) {
- this.infos = infos;
- }
-
- public Boolean isModifiedKmlData() {
- return modifiedKmlData;
- }
-
- public void setModifiedKmlData(Boolean modifiedKmlData) {
- this.modifiedKmlData = modifiedKmlData;
- }
-
- @Lob
- @Basic(fetch = FetchType.LAZY)
- public byte[] getLogo() {
- return logo;
- }
-
- public void setLogo(byte[] logo) {
- this.logo = logo;
- }
-
- @Lob
- @Basic(fetch = FetchType.LAZY)
- public byte[] getCertificateTemplate() {
- return certificateTemplate;
- }
-
- public void setCertificateTemplate(byte[] certificateTemplate) {
- this.certificateTemplate = certificateTemplate;
- }
-
- // TODO V3: warning, not conditional now! Verify if it works as
espected. @Email(applyIf="contactEmail is not blank")
- @Email
- public String getContactEmail() {
- return contactEmail;
- }
-
- public void setContactEmail(String contactEmail) {
- this.contactEmail = contactEmail;
- }
-
- public String getContactName() {
- return contactName;
- }
-
- public void setContactName(String contactName) {
- this.contactName = contactName;
- }
-
- public String getTimeZoneId() {
- return timeZoneId;
- }
-
- public void setTimeZoneId(String timeZoneId) {
- this.timeZoneId = timeZoneId;
- }
-
- public String getInternalFriendlyName() {
- return internalFriendlyName;
- }
-
- public void setInternalFriendlyName(String internalFriendlyName) {
- this.internalFriendlyName = internalFriendlyName;
- }
-
- @Transient
- public String getWebSiteUrl() {
- String result = this.getWebSite();
- if (this.getWebSite() != null
&& !this.getWebSite().contains("://")) {
- result = "http://" + result;
- }
- return result;
- }
-
- @Transient
- public String getFriendlyNameEncoded() throws
UnsupportedEncodingException {
- String result = null;
- if (StringUtils.isNotBlank(getInternalFriendlyName())) {
- result = getInternalFriendlyName();
- } else {
- result = getName();
- }
- return URLEncoder.encode(result, "UTF-8");
- }
-}
=======================================
***Additional files exist in this changeset.***
==============================================================================
Revision: 17e004354209
Branch: default
Author: enricogiurin
Date: Fri May 24 23:13:44 2013
Log: issue-118
http://code.google.com/p/jugevents/source/detail?r=17e004354209&repo=version3
Added:
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/Utilities.java
=======================================
--- /dev/null
+++
/jugevents/jugevents-core/src/main/java/org/jugevents/core/util/Utilities.java
Fri May 24 23:13:44 2013
@@ -0,0 +1,67 @@
+/**
+ * Copyright (C) 2007-2011 JUG Events Team <
in...@jugevents.org>
+ *
+ * This file is part of JUG Events - Core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jugevents.core.util;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Date;
+
+import org.joda.time.DateMidnight;
+
+
+
+public class Utilities {
+ public static boolean todayIsBeforeDate(final Date date) {
+ boolean result;
+ // old way
+ DateMidnight today = new DateMidnight();
+ result = today.compareTo(new DateMidnight(date)) <= 0;
+ return result;
+ }
+
+ /**
+ * Append a parameter to an URL.
+ *
+ * @param sb The StringBuilder containing the URL where to append.
+ * @param parameterName The name of the parameter
+ * @param parameterValue The value of the parameter. It will be url
encoded.
+ * @param ifNotNull if true the parameter is appended only if its
vale is not null.
+ * @return The passed StringBuilder
+ */
+ public static StringBuilder appendUrlParameter(StringBuilder sb,
+ String parameterName, String parameterValue, boolean
ifNotNull)
+ throws UnsupportedEncodingException {
+ if (ifNotNull && parameterValue == null) {
+ return sb;
+ }
+ if (sb.indexOf("?") == -1) {
+ sb.append('?');
+ }
+ if (sb.charAt(sb.length() - 1) != '?') {
+ sb.append('&');
+ }
+ sb.append(parameterName).append('=');
+ if (parameterValue != null) {
+ sb.append(URLEncoder.encode(parameterValue, "UTF-8"));
+ }
+ return sb;
+ }
+
+
+
+}