001
014
015 package com.liferay.portlet.social.util;
016
017 import com.liferay.portal.kernel.util.StringPool;
018 import com.liferay.portlet.social.model.SocialRelationConstants;
019
020 import java.util.Arrays;
021 import java.util.List;
022
023
026 public class SocialRelationTypesImpl implements SocialRelationTypes {
027
028 @Override
029 public List<Integer> getAllSocialRelationTypes() {
030 return _allSocialRelationTypes;
031 }
032
033 @Override
034 public String getTypeLabel(int type) {
035 if (type == SocialRelationConstants.TYPE_BI_CONNECTION) {
036 return "connection";
037 }
038 else if (type == SocialRelationConstants.TYPE_BI_COWORKER) {
039 return "coworker";
040 }
041 else if (type == SocialRelationConstants.TYPE_BI_FRIEND) {
042 return "friend";
043 }
044 else if (type == SocialRelationConstants.TYPE_BI_ROMANTIC_PARTNER) {
045 return "romantic-partner";
046 }
047 else if (type == SocialRelationConstants.TYPE_BI_SIBLING) {
048 return "sibling";
049 }
050 else if (type == SocialRelationConstants.TYPE_BI_SPOUSE) {
051 return "spouse";
052 }
053 else if (type == SocialRelationConstants.TYPE_UNI_CHILD) {
054 return "child";
055 }
056 else if (type == SocialRelationConstants.TYPE_UNI_ENEMY) {
057 return "enemy";
058 }
059 else if (type == SocialRelationConstants.TYPE_UNI_FOLLOWER) {
060 return "follower";
061 }
062 else if (type == SocialRelationConstants.TYPE_UNI_PARENT) {
063 return "parent";
064 }
065 else if (type == SocialRelationConstants.TYPE_UNI_SUBORDINATE) {
066 return "subordinate";
067 }
068 else if (type == SocialRelationConstants.TYPE_UNI_SUPERVISOR) {
069 return "supervisor";
070 }
071
072 return StringPool.BLANK;
073 }
074
075 @Override
076 public boolean isTypeBi(int type) {
077 return !isTypeUni(type);
078 }
079
080 @Override
081 public boolean isTypeUni(int type) {
082 if ((type == SocialRelationConstants.TYPE_UNI_CHILD) ||
083 (type == SocialRelationConstants.TYPE_UNI_ENEMY) ||
084 (type == SocialRelationConstants.TYPE_UNI_FOLLOWER) ||
085 (type == SocialRelationConstants.TYPE_UNI_PARENT) ||
086 (type == SocialRelationConstants.TYPE_UNI_SUBORDINATE) ||
087 (type == SocialRelationConstants.TYPE_UNI_SUPERVISOR)) {
088
089 return true;
090 }
091 else {
092 return false;
093 }
094 }
095
096 private static final List<Integer> _allSocialRelationTypes = Arrays.asList(
097 SocialRelationConstants.TYPE_BI_CONNECTION,
098 SocialRelationConstants.TYPE_BI_COWORKER,
099 SocialRelationConstants.TYPE_BI_FRIEND,
100 SocialRelationConstants.TYPE_BI_ROMANTIC_PARTNER,
101 SocialRelationConstants.TYPE_BI_SIBLING,
102 SocialRelationConstants.TYPE_BI_SPOUSE,
103 SocialRelationConstants.TYPE_UNI_CHILD,
104 SocialRelationConstants.TYPE_UNI_ENEMY,
105 SocialRelationConstants.TYPE_UNI_FOLLOWER,
106 SocialRelationConstants.TYPE_UNI_PARENT,
107 SocialRelationConstants.TYPE_UNI_SUBORDINATE,
108 SocialRelationConstants.TYPE_UNI_SUPERVISOR);
109
110 }