Adds a profile to the drawer view

@param profile Profile to add
195950
public DrawerView addProfile(DrawerProfile profile) {
        if (profile.getId() <= 0) {
            profile.setId(System.nanoTime() * 100 + Math.round(Math.random() * 100));
        }
        for (DrawerProfile oldProfile : mProfileAdapter.getItems()) {
            if (oldProfile.getId() == profile.getId()) {
                mProfileAdapter.remove(oldProfile);
                break;
            }
        }
        profile.attachTo(this);
        mProfileAdapter.add(profile);
        if (mProfileAdapter.getCount() == 1) {
            selectProfile(profile);
        }
        updateProfile();
        return this;
    }
1356048
public <F> void updateProfileField(ProfileField<F, ?> field, F... values) {
		updateProfileField(field, Arrays.asList(values));
	}
322269
private void onProfileImageClick(View v, boolean current) {
        IProfile profile = (IProfile) v.getTag(R.id.material_drawer_profile_header);

        boolean consumed = false;
        if (mOnAccountHeaderProfileImageListener != null) {
            consumed = mOnAccountHeaderProfileImageListener.onProfileImageClick(v, profile, current);
        }

        //if the event was already consumed by the click don't continue. note that this will also stop the profile change event
        if (!consumed) {
            onProfileClick(v, current);
        }
    }
118937
def addProfile(self, profile):
        
        # use the existing version
        for exist in self.profiles():
            if exist.name() == profile.name():
                if exist.version() < profile.version():
                    exist.setProfile(profile)
                
                return
        
        # otherwise create a new profile 
        act = XViewProfileAction(profile, self)
        self._profileGroup.addAction(act)
        self.addAction(act)
        return act
1319136
public void buildProfileDoc(XMLNode node, Content contentTree) throws Exception {
        contentTree = profileWriter.getProfileHeader(profile.name);
        buildChildren(node, contentTree);
        profileWriter.addProfileFooter(contentTree);
        profileWriter.printDocument(contentTree);
        profileWriter.close();
        Util.copyDocFiles(configuration, DocPaths.profileSummary(profile.name));
    }
417130
public Service setSupportedServiceProfiles(Iterable<ServiceProfile> profiles)
    {
        if (profiles == null)
        {
            this.supportedServiceProfiles = null;

            return this;
        }

        Set<ServiceProfile> set = new TreeSet<ServiceProfile>();

        for (ServiceProfile profile : profiles)
        {
            if (profile != null)
            {
                set.add(profile);
            }
        }

        int size = set.size();

        if (size == 0)
        {
            this.supportedServiceProfiles = null;

            return this;
        }

        ServiceProfile[] array = new ServiceProfile[size];
        this.supportedServiceProfiles = set.toArray(array);

        return this;
    }
89073
public void setUserProfiles(java.util.Collection<UserProfile> userProfiles) {
        if (userProfiles == null) {
            this.userProfiles = null;
            return;
        }

        this.userProfiles = new com.amazonaws.internal.SdkInternalList<UserProfile>(userProfiles);
    }
975333
private void updateCachedLayout(
            Document layout, IUserProfile profile, FragmentDefinition fragment) {
        final Locale locale = profile.getLocaleManager().getLocales().get(0);
        // need to make a copy that we can fragmentize
        layout = (Document) layout.cloneNode(true);

        // Fix later to handle multiple profiles
        final Element root = layout.getDocumentElement();
        final UserView userView = this.fragmentUtils.getUserView(fragment, locale);
        if (userView == null) {
            throw new IllegalStateException(
                    "No UserView found for fragment: " + fragment.getName());
        }

        root.setAttribute(
                Constants.ATT_ID,
                Constants.FRAGMENT_ID_USER_PREFIX
                        + userView.getUserId()
                        + Constants.FRAGMENT_ID_LAYOUT_PREFIX
                        + "1");
        try {
            this.fragmentActivator.clearChacheForOwner(fragment.getOwnerId());
            this.fragmentUtils.getUserView(fragment, locale);
        } catch (final Exception e) {
            logger.error("An exception occurred attempting to update a layout.", e);
        }
    }
1193160
@Override
    public UserProfile addUserProfile(final IPerson person, final IUserProfile profile) {
        final int userId = person.getID();
        final int layoutId = getLayoutId(person, profile);
        // generate an id for this profile

        return jdbcOperations.execute(
                (ConnectionCallback<UserProfile>)
                        con -> {
                            String sQuery;
                            PreparedStatement pstmt =
                                    con.prepareStatement(
                                            "INSERT INTO UP_USER_PROFILE "
                                                    + "(USER_ID, PROFILE_ID, PROFILE_FNAME, PROFILE_NAME, STRUCTURE_SS_ID, THEME_SS_ID,"
                                                    + "DESCRIPTION, LAYOUT_ID) VALUES (?,?,?,?,?,?,?,?)");
                            int profileId = getNextKey();
                            pstmt.setInt(1, userId);
                            pstmt.setInt(2, profileId);
                            pstmt.setString(3, profile.getProfileFname());
                            pstmt.setString(4, profile.getProfileName());
                            pstmt.setInt(5, profile.getStructureStylesheetId());
                            pstmt.setInt(6, profile.getThemeStylesheetId());
                            pstmt.setString(7, profile.getProfileDescription());
                            pstmt.setInt(8, layoutId);
                            sQuery =
                                    "INSERT INTO UP_USER_PROFILE (USER_ID, PROFILE_ID, PROFILE_FNAME, PROFILE_NAME, STRUCTURE_SS_ID, THEME_SS_ID, DESCRIPTION, LAYOUT_ID) VALUES ("
                                            + userId
                                            + ",'"
                                            + profileId
                                            + ",'"
                                            + profile.getProfileFname()
                                            + "','"
                                            + profile.getProfileName()
                                            + "',"
                                            + profile.getStructureStylesheetId()
                                            + ","
                                            + profile.getThemeStylesheetId()
                                            + ",'"
                                            + profile.getProfileDescription()
                                            + "', "
                                            + profile.getLayoutId()
                                            + ")";
                            logger.debug("addUserProfile(): {}", sQuery);
                            try {
                                pstmt.executeUpdate();

                                UserProfile newProfile = new UserProfile();
                                newProfile.setProfileId(profileId);
                                newProfile.setLayoutId(layoutId);
                                newProfile.setLocaleManager(profile.getLocaleManager());
                                newProfile.setProfileDescription(profile.getProfileDescription());
                                newProfile.setProfileFname(profile.getProfileFname());
                                newProfile.setProfileName(profile.getProfileName());
                                newProfile.setStructureStylesheetId(
                                        profile.getStructureStylesheetId());
                                newProfile.setSystemProfile(false);
                                newProfile.setThemeStylesheetId(profile.getThemeStylesheetId());

                                return newProfile;

                            } finally {
                                pstmt.close();
                            }
                        });
    }
1259154
def saveProfileAs( self ):
        
        name, ok = QInputDialog.getText(self, 'Create Profile', 'Name:')
        if ( not name ):
            return
        
        manager = self.parent()
        prof    = manager.viewWidget().saveProfile()
        prof.setName(nativestring(name))
        self.parent().addProfile(prof)
724864
public static <U extends UserProfile> Optional<U> flatIntoOneProfile(final Collection<U> profiles) {
        final Optional<U> profile = profiles.stream().filter(p -> p != null && !(p instanceof AnonymousProfile)).findFirst();
        if (profile.isPresent()) {
            return profile;
        } else {
            return profiles.stream().filter(p -> p != null).findFirst();
        }
    }
258215
public void setProfiles(java.util.Collection<ProfileData> profiles) {
        if (profiles == null) {
            this.profiles = null;
            return;
        }

        this.profiles = new java.util.ArrayList<ProfileData>(profiles);
    }
892757
protected void loadProfileIfNeeded()
    {
        final Object key = getProfileKey();
        if (key != null)
        {
            final MetadataManager mm = MetadataManager.getInstance();
            if (!key.equals(mm.getCurrentProfileKey()))
            {
                mm.loadProfile(key);
            }
        }
    }
86364
protected void addAllProfilesLink(Content div) {
        Content linkContent = getHyperLink(DocPaths.PROFILE_OVERVIEW_FRAME,
                allprofilesLabel, "", "packageListFrame");
        Content span = HtmlTree.SPAN(linkContent);
        div.addContent(span);
    }
1034080
private void saveUserProfile(Session session, UserProfile profile, boolean broadcast) throws RepositoryException,
      Exception
   {
      Node userNode = utils.getUserNode(session, profile.getUserName());
      Node profileNode = getProfileNode(userNode);

      boolean isNewProfile = profileNode.isNew();

      if (broadcast)
      {
         preSave(profile, isNewProfile);
      }

      writeProfile(profile, profileNode);

      session.save();
      putInCache(profile);

      if (broadcast)
      {
         postSave(profile, isNewProfile);
      }
   }
1062981
def addProfile(self, profile):
        
        if ( profile in self._profiles ):
            return
        
        self._profiles.append(profile)
        self._profileCombo.blockSignals(True)
        self._profileCombo.addItem(profile.name())
        self._profileCombo.setCurrentIndex(self._profileCombo.count()-1)
        self._profileCombo.blockSignals(False)
595593
public DrawerView clearProfiles() {
        for (DrawerProfile profile : mProfileAdapter.getItems()) {
            profile.detach();
        }
        mProfileAdapter.clear();
        updateProfile();
        return this;
    }